Invoke install4j updater with custom proxy settings - install4j

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)

Related

Creating VSCode Debugger Extension

I'm in the process of trying to write a VSCode extension to support basic SNES application development. I already have a basic grammar definition and build task, so I have syntax highlighting, and am able to build my project with Ctrl+Shift+B using the bass v14 assembler, but now I'm trying to figure out how to launch the project using launch.json. I've already worked through the official docs and played around with the mock debugger project, but I can't seem to figure out how to adapt it for my extension. To start, I'm using the bsnes-plus emulator as my debugger. There isn't really any command-line or IPC interface that will actually allow me to implement a proper debug adapter, so all I really want to do is to run the program and pass it my output file to launch. For the time being, I'm assuming that bsnes-plus.exe is located in my $PATH, but eventually I'll try and figure out the best practices for external executable dependencies for an extension.
So here are my current questions:
Is the "program" field of launch.json my compiled application, or is it bsnes-plus.exe?
If "program" is my application, where do I specify bsnes-plus.exe? Or vice versa.
Is there a way to specify my own project-level variables, e.g. $OUTPUT so that I don't have to hard-code the output filename into both the build task and the launch task?
At one point, I was able to get the launch command to open bsnes-plus, but not load the game, and when I closed it, VSCode complained that the debugger terminated unexpectedly and immediately re-opened bsnes-plus. How do I avoid this? Do I need to write a debug adapter even though it's not going to actually do anything other than launch the application, just so I can tell VSCode that it exited cleanly?
Is the "program" field of launch.json my compiled application, or is it bsnes-plus.exe?
This is entirely up to the debug extension. It's just passed through to the debug adapter. It usually corresponds to the specific app/script being debugged though, not the runtime that's running it, so I would suggest it should be your compiled application.
If "program" is my application, where do I specify bsnes-plus.exe? Or vice versa.
You can put it any other field. In Dart, we have a dartPath field that can be passed through to the debug adapter. It's usually populated silently by the DebugConfigurationProvider.resolveDebugConfig though (we detect the SDK by searching PATH) so the user never needs to add it.
Is there a way to specify my own project-level variables, e.g. $OUTPUT so that I don't have to hard-code the output filename into both the build task and the launch task?
You can't make your own variables, but using resolveDebugConfig you can manipulate the launch config yourself before it's passed to the debug adapter, which probably allows you to do what you need here (eg. you could do a string replace on program - or you could even just add it if it's not set, allowing a launch.json-less launch too).
Do I need to write a debug adapter even though it's not going to actually do anything other than launch the application, just so I can tell VSCode that it exited cleanly?
I'm not sure what happened here without more details, but having a debug adapter probably makes the most sense - for example if you want to make the Stop/Restart buttons work on the toolbar, you'd probably want a debug adapter that can terminate and/or restart the process.

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

Convenient way to run eclipse plugin

I have recently started developing an Eclipse plugin (which is basic stuff for now) and I am struggling with "default" way to run Eclipse plugin ("Run as Eclipse application").
The Eclipse is starting another instance with my plugin already installed in it (this is default behaviour).
The problem is that when I want to re-run my plugin project and I press "run" button again (or Ctrl + F11) (and the another Eclipse instance still running) I get following message:
"Could not launch the application because the associated workspace is currently in use by another Eclipse application".
The error makes sense, and when I close "testing" Eclipse instance I am able to run my plugin again.
The question is - "is it normal routine for plugin development?". Maybe I am missing something, e.g. special arguments for Eclipse?
This seems all pretty normal. The error message is since the run configuration is specifing a workspace and when you start a second instance using the same workspace it is locked and considered in use.
What I usually do when testing a plugin is to create a run configuration (click "Run...") where I disable all the plugins I wont need when testing. This makes sure that the test starts up a couple of seconds quicker. Make sure you save that run configuration as a *.launch file aswell, that makes it quicker to test the next time. Or it can be used to share the configuration.
There's a lot you can configure in the run configuration, such as eclipse arguments, vm argument, if you want environment variables set, etc. So be sure to experiment a little.
In your run configuration. Main tab->Workspace Data ->Location text box add this:
${workspace_loc}/../runtime-EclipseApplication${current_date:yyyyMMdd_HHmmss}
Note the suffix ${current_date:yyyyMMdd_HHmmss} by this every time you launch your application new workspace will be created. So you will not get any error message saying workspace is locked.
But be careful as the folder .metadata will be different for different instances as their work-spaces are different. Thus preferences stored/retrieved by different instances are NOT in sync.
You are probably missing one important point: Eclipse supports the Java hot code replacement. Therefore in many cases you can modify your Java code while your application Eclipse instance is running, save the code and continue without restarting.
If hot code replacement is not possible, Eclipse will tell you, so you always know whether the editing changes are applied to the running instance.
This works best with more recent versions of the JVM, so consider upgrading to the latest Java 7 version, even if you write code to be compliant with Java 1.5 or 6.

Passing proxy settings to a bundled JRE install4j application?

We provided an application installed with install4j, with bundled JRE, to one of our customers. This customer needs some proxy settings configured manually for this application.
I tried to put deployment.config file in the JRE's lib directory but it didn't seem to change anything. I couldn't find a relevant vmoptions either.
Is there a way to pass these settings to the app/jre?
Is there also a way to instruct the JRE to open the Java console when it runs?
Thanks!
/Shmulik.
You can configure the proxy by setting the VM parameters
proxySet=true
proxyHost=...
proxyPort=...
and for authentication
proxyAuth=true
proxyAuthUser=...
proxyAuthPassword=...
You can set them either in a "Run script" in the startup node of the installer action by calling System.setProperty() for the properties or by passing them on the command line like this:
-DproxySet=true -DproxyHost=... etc
As for your second question (better to ask a separate question on stackoverflow)
Is there also a way to instruct the JRE to open the Java console when it runs?
I assume you mean a terminal window, which can be done by selecting the "Windows console executable" property of the installer. You cannot change this property on the command line because this sets a static flag in the binary format of the Windows executable furing compilation.
I created an installer for WINDOWS as well as for MAC. The
application is using an embedded JRE. While the application runs, it's not
able to detect the proxy settings of the network even the option in
the browser is set to be "Auto Detect". But when the proxy settings provided explicitly in the browser, it's able to detect the proxy settings.
Even the proxy settings are not detected when "LAN Settings->Use automatic configuration script" option is selected and points to the .pac file.
Any suggestion, how to provide the proxy settings with BUNDLED JRE and java program can detect those settings without make any further changes in each machine.

How to run GWT RequestFactory Validation Tool on Eclipse project

I've got a Android AppEngine Connected Project I'm trying to build using GWT2.4 RequestFactory and Objectify on my Eclipse IDE.
Apparently I need to run the RequestFactory Validation Tool because I'm using ServiceName and ProxyForName annotations (these are required especially when working on the Android client side). My problem is the Eclipse can't validate it and the solution provided at http://code.google.com/p/google-web-toolkit/wiki/RequestFactoryInterfaceValidation#IDE_configuration is enough to make me rip my eyes out.
Since I'm working on a Windows machine, the shell script provided is not very useful. Trying to run Validation Tool from a cmd propt returns the error message:"This tool must be run with a JDK, not a JRE"
Can someone explain how this Tool is supposed to be run? Is there a way to use it as an External Tool in eclipse?
Normally if you follow carefully the instructions in the link you show, and run the GWT Development Mode from Eclipse, the Validation should be done automatically at the time you access the development URL with your browser.
For the record, I've actually had some problems with it, but launching the application several times maked it work.
Well, I ran into the same problem as well. When I tried annotation processing (under Java Compiler-> Annotation processing )was being disabled. So RequestFactoryDeobfuscatorBuilder was not being generated. Try enabling that and rebuilding your project.
I've just recovered from two days of hunting this bug down in a project that used to run validation properly but stopped.
In my case I had a new-ish generic BaseRequestContext and a specific sub-interface that extended it. My parent interface declared a method that didn't match the Locator's exactly (e.g. getThing(T) vs get(T)) and this wasn't reported as an error but did stop the validation tool from completing.
Apt is also removed in Java 8 : http://openjdk.java.net/jeps/117 . So beware.
Switching back to Java 7 will fix the issue if you are using Java 8.
I understood why the error happens sometimes in a project: the compiler was complaining it cannot find the directory .apt . But when I tried to create it manually it was not possible (under windows). I think the validation tool mutes the exception of not being able to create the directory: try renaming .apt in your validation tool calls (do a text search in your project)