Install4j with javaagents? - install4j

We tried to use -javaagent with an install4j bundled application. This doesn't work because the statement of the -javaagent has to be first in the parameter list.
But install4j sets its own parameters at the first position and I don't know how to get a -javaagent parameter to the first position. I activate the install4j log and see that other parameters are always the first.
Another possibility would be to use a JDK to start the install4j bundled application, but you can only use JREs an no JDKs. With a JDK you could register JavaAgents dynamically via the Java class VirtualMachine.

The -javaagent does not have to be the first argument, but it has to be a VM parameter and not an argument to the main class. Arguments to an executable created by install4j are passed to the main class, unless they are prefixed with -J in which case they are passed as VM parameters.
So you pass
-J-javaagent:...
on the command line, it will be passed properly.
See install4j manual, scroll to "Passing VM parameters on the command line".

Related

Incorrect VM arguments in Tibco6.x Designer

I created a tibco 6.3 BW application using tibco designer on Windows.Application is running fine but whenever I try to add Vm arguments (under Arguments tab) in Run Configurations Menu they gets modified after I close the menu. I was trying to add debug arguments
-agentlib:jdwp=transport=dt_socket,server=y,address=9090,suspend=n
for debugging the application but they always gets modified so that some '=' sign changes into space. So whenever I edit vm args and try to run the application I get invalid arguments error.
I think the problem is similar to this https://superuser.com/questions/392230/incorrect-vm-arguments-in-myeclipse-run-configuration
Any help would be appreciated.
Although I don't know why it was happening, but I found a workaround by supplying vm arguments directly to jre, by going to preferences --> java --> Installed JREs --> Edit JRE --> Default Vm Arguments.

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

Invoke install4j updater with custom proxy settings

I want to do the following with application wrapped by Install4J:
have the Install4J Updater invoked from the code of the wrapped Java app
show the GUI dialogs, configured in the Install4J IDE to a user if there is an update available
pass custom proxy parameters to the Updater, if required
As far as I can understand Install4J I should be able to do it with the following:
List<String> args = new ArrayList<String>();
args.add("-DproxySet=true");
args.add("-DproxyHost="+MY_PROXY_SERVER);
args.add("-DproxyPort="+MY_PROXY_PORT););
args.add("-DproxyAuth=true");
args.add("-DproxyAuthUser="+MY_PROXY_USERNAME);)
args.add("-DproxyAuthPassword="+MY_PROXY_PASSWORD);
ApplicationLauncher.launchApplicationInProcess(
MY_UPDATER_ID.toString(),
args.toArray(new String[args.size()]),
null,
ApplicationLauncher.WindowMode.FRAME,
null);
but I keep getting the popup for entering proxy details.
I have tried changing parameters not to have prefix "-D", tried switching Updater to console mode or unattended mode, not passing the parameters but rather putting them to JVM directly with System.setProperty()... but with no success. I always ended either with proxy-popup or with message that "The update information could not be downloaded from ____ Please check your network settings."
Also: if I repeatedly invoke Updater but with different parameters the popup always shows the once I used for the first invocation.
Any help?
Thanks in advance.
Thanks to the support from EJ-tehnologies (developers of Install4J) we got the proxy thing working. In the moment of asking the question we were using v5.0.11, and they instructed us to use v5.1.2 (latest stable build in that moment). And finally we ended using the beta release v5.1.3 (not publicly available at the moment).
Details on how to have proxy working, without popup and with using dynamic parameters:
to the code above add additional argument that will prevent Install4J to detect system wide proxy settings:
args.add("-Dinstall4j.noProxyAutoDetect=true");
use method ApplicationLauncher.launchApplication() for invoking the Install4J wrapper as it will start it in the new JVM. starting like this is required due to JVM's handling of existing env variables, so if you start Install4J in the same JVM and append arguments in that JVM the Install4J might not pick the latest values (this is if you want to dynamically change proxy params)
wait for v5.1.3 to become stable and download it as it will support "not showing" of proxy popup dialog when proxy parameters are explicitly given to Install4J (this is my guess, I'm not speaking in the name of people from EJ-technologies)

Arguments to PyUnit not parsed correctly

When we try to run a PyUnit test in Eclipse as a Python unit-test, it fails. This is because the arguments sent to PyUnit come in the following order: file-to-test --port portno. We have discovered that there is an environment variable called POSIXLY_CORRECT that, if set, makes PyUnit expect the arguments to come in a certain order, options first.
We have looked everywhere in Eclipse to try and find where these arguments are set, but are unable to find them. So as a workaround we change the run configuration to use an environment without the POSIXLY_CORRECT set. But this is very awkward.
Does anyone know how to solve this so that we do not need to modify the run configurations to be able to run our tests?

How to pass server.{host,port} to grails under Eclipse/STS

I need to set grails.server.host and grails.server.port differently on different dev machines, or in different configurations. I can set them in BuildConfig.groovy but that is source-controlled so I don't want to check in machine-specific info there. How can I pass these from the Run Configuration?
I have tried every combination of -Dserver.host and -Dgrails.server.host, with the values in quotes or not, in the Arguments tab Program Arguments and VM Arguments fields, and just server.host or grails.server.host in the Environment tab; I even tried changing the Grails tab's Grails Command field to "-Dserver.host=192.168.2.110 run-app" but grails keeps coming up "localhost:8080"
My fallback is to try and set them with an external property file, but then I have to get fancy about setting them differently for different environments and such, and I don't have easy UI visibility like I do with the Run As ... menu. So, can someone tell me how they are configuring Eclipse/STS to pass a grails parameter?
(Using Eclipse (STS 2.7.1) with grails 2.0.0M1)
-Dserver.host=192.168.2.110 -Dserver.port=8888 Should work if set in the VM arguments...
Have you tried grails -Dserver.host=192.168.2.110 -Dserver.port=8888 run-app from terminal or the command prompt?