Execution level start app on second start doesn't call main method from code - install4j

I'm using install4j to create an installer for my java application.
I'm using executable level "As invoker" and in the first start after installation, the application works fine calls all my loggers from the main class and all other classes. On the second start, an application doesn't call my main class. If I use the executable level "Administrator" application works fine.
Can somebody explain to me how to fix this?

Related

How to debug soap UI scripts using Eclipse

I have written some libraries which is in groovy.
My SOAP UI scripts which is currently used for API automation is using these libraries. As there is no debug option in SOAP UI Pro It is very hard to find the failures. Can someone help to debug the groovy script from eclipse. Which is called internally by a SOAP UI Script
Here is the way I get it done:
Instead of writing the logic in a groovy script using soapUI script editor, create groovy/java (user choice) class and its methods for the same logic. Here I assume that the script would have relative lots of lines code than fewer lines.
This has couple of advantages:
Intelli sense (which is not available if you write the same in soapUI tool)
Formatting of code
Easy debug
Maintenance of the code would be simple
Have a groovy/java project in the IDE of your choice (Intellij suits better for groovy projects, personal view only). Have the logic in the form of classes / methods. Compile those classes and create a jar file. Place it under SOAPUI_HOME/bin/ext directory.
Edit the soapui invoking script(SOAPUI_HOME/bin/soapui.sh on unix or .bat on windows) and add the debug parameters in JAVA_OPTS say
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=6006.
In the groovy script, just instantiate the above created class and call the appropriate method. Use arguments to your methods, that are available in groovy script context, log, testRunner etc variables. Even the script is done with fewer lines.
Debugging In Action:
In your IDE, configure remote debugging and add your debug points where it is needed. And start debug.
Now, just run the groovy script. Go to IDE, it should stop at the point where you added the debug point. You should be to do run through it normally like how you do with java projects in your IDE.
This works best for me.
EDIT:
Of course, this requires programming knowledge, know working in IDE (assuming that user knows as per the question) configuring build/class path etc.
Can't be done. SmartBear has been talking about this since at least 2007 (when SoapUI was still owned by Eviware), but still has not delivered. Here is one source: http://community.smartbear.com/t5/SoapUI-NG/Debugging-Groovy-scripts/td-p/33995

How do I run some Scala code when the JVM starts?

The problem I have is that I need to do some System.properties modifications and checks when the application starts AND when tests start running.
How do get code to run basically as soon as the JVM can start running code? I tried a package object but I couldn't seem to get it to execute the code unless it was invoked.
Just make all your test classes extend an abstract base class which calls the initialization code in the constructor.

Mac: attach commandline parameters to a running application on Mac failed

Today I have a strange problem on MacOs. I hope I can explain the precondition exactly for understanding. We are using the install4j version 6.0.1.
Our application is implemented with an install4j silent update check application as the main "launcher" to check for updates during the startup process of our application. This application is totally configured by the install4j IDE. It checks whether an update exists and for that downloads the new installer and executes it. That's working fine. If the application is up-to-date the "main" application launcher will be executed by the Execute Launcher-action. Therefore the "extraCommandLineArguments" will be passed to the launcher and the application will be started. That's working also fine and the parameters will be passed correctly to our main class.
Now the strange behavior: when I start the application twice with several parameters during the first instance is always running the parameters will not be passed to the first instance neither a second instance will be created. The launcher is configured by install4j to allow multiple instances of the application and the single-instance option is implemented by our application itself. Therefore the main-class checks whether an instance is always running and will pass the parameters to the first instance. Now it seems that the second instance will never be created because I can't attach to the vm-process by IDE at debug mode. Therefore I set the debug vm parameters to the vmoption file. I tried several options to start the second instance:
execute our application normally with the "updater"-application and set commandline parameters
execute our application directly by the launcher-executable and set commandline parameters
execute our application by calling the JavaApplicationStub of the launcher and passing the commandline parameters to it
For all options the running instance will get the focus but do not receive any parameter and I can not attach the second process by the IDE to debug the behavior. It seems our application (main-class) will not be executed a second time. At the Info.plist file there is the MacLauncher class recognized as the main-class. Is tere any logic implemented to search for a running instance and ignore a second one?
The strange thing is: at windows everything works fine. The second process passes the parameter to the running instance. What could be different on mac? How can I check whether install4j is calling our main application class configured at the launcher? Are there any debug-options?
Thanks in advance for any help.
On Mac OS X, GUI applications are in single instance mode by default. This is a property of the Mac OS X desktop environment. The only way to open a second instance, is to call
open -n my.app

Running an Eclipse Builder before program launch

I'm trying to write an Eclipse plug-in which takes part in the build process. However, I'd like my Builder to execute only before the user tries to launch his program, and not during normal compilation.
As an example, I noticed that part of the Android SDK builder is executing during compilation, but other parts only before program launch (the APK builder), and I'm trying to do the same.
I've extended IncrementalProjectBuilder, and my build() method gets called during incremental and full builds, but I couldn't find a way to make it run only before the user tries to launch the program (run or debug).
Any thoughts?
Thanks,
Ariel

Automatically Activate Plugin in NetBeans

Can I create a module for NetBeans that runs in the background as soon as the user opens the NetBeans IDE? For example, I am building a plugin that captures the source code of the active JTextComponent (active code editor) in NetBeans, but I would like this plugin to always run in the background without having to be activated by the user clicking a button or pressing some key combination.
Is this possible, and if so, what is the best way of doing it?
Yeah, just create a "Install.java" inside the root package of your module and subclass it with ModuleInstall class, then start a process that runs continuously inside the restored() methods. The restored() method gets called on module installation and everytime netbeans starts. So your process will start as soon as the module is loaded in Netbeans.
ModuleInstall
Also checkout this section from DevFaqModulesGeneral.
Programmatic registration - ModuleInstall classes The module system
allows you to provide a ModuleInstall class, which runs some code
during startup or when the module is loaded, and can run cleanup code
when it is uninstalled or disabled. This is the least desirable way
to do things, because running code on startup means slowing down
startup. Before you use such a class, be sure there is no declarative
way to do what you're trying to do; see:
DevFaqModulesDeclarativeVsProgrammatic
To have some code run on startup/installation/uninstallation/etc., add
a line like the following to your module's manifest file:
OpenIDE-Module-Install: org/netbeans/modules/paintcatcher/PaintCatcherModule.class
This line should be part of the group of lines at the top of the
manifest, with no blank lines before it. It is a pointer to a class
file inside the module. The class file must extend the class
org.openide.modules.ModuleInstall. There is a wizard in the
development support to create and register such a class for you.