Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combination of Launch4J and Java Web Start?

I have a working JNLP application which I need to distribute to various non-technical end users.

If the user's machine has a recent JVM installed, everything is fine. They just double-click the JNLP file I send them and Java Web Start does the rest.

Now I would like to distribute something that works with or without a JVM, e.g. a .exe file that auto-downloads a compatible JVM if none is present, then invokes javaws.exe to download the .jar files and launch the application.

Launch4J is the closest match I have found, but it cannot launch a program through javaws.exe. The only options are java and javaw

I would like a product that can:

  • Generate a self-contained .exe file that does not require a JVM to be pre-installed
  • Parse the .jnlp file and determine the correct JVM to download if necessary (I know Java Web Start can download a JVM if necessary, but I want to avoid having to download two, the first to bootstrap Java Web Start and the second to run the application which may require a specific but different JVM.)
  • Download and install the JVM automatically, not simply direct the user to a Java download page or open a new installation wizard.
  • Prompt for an admin password if necessary (for permissions to install the JVM. I don't think this is built into the Sun JVM installers.)
  • Show only one security dialog (I would like to prompt the user just once, to confirm they trust the generated .exe, but I do not want a second prompt to confirm they trust the .jar file which will be from the same source and signed with the same certificate.) I assume this will require the auto-downloader to install the certificate before launching JWS.)
  • (not essential) Download application resources (e.g. .jar files) in the background simultaneously with the JVM. This would require the cache to be running before the JVM is installed, so the cache would have to be implemented in native code and the DownloadService would later interface to it using JNI.

Does a product like this exist? I suspect it does not but It's worth a shot.


Update I found this article which has solutions to some related problems, though it is designed for offline installation and I am mostly concerned with online installation.

like image 693
finnw Avatar asked Jul 31 '10 23:07

finnw


People also ask

How do I associate JNLP with Java Web Start?

Open Firefox and select 'Options'. 3. Under the 'General' category, scroll down to the 'Applications' section. Click the drop down menu for 'JNLP files' and select 'Use Java Web Start Launcher'.

What is JNLP file in Java?

The Java Network Launch Protocol (JNLP) enables an application to be launched on a client desktop by using resources that are hosted on a remote web server. Java Plug-in software and Java Web Start software are considered JNLP clients because they can launch remotely hosted applets and applications on a client desktop.

How do I run a JNLP file in Java?

Right-click a JNLP file and click “Open With.” Select the “Java Web Start Launcher” application in the list or click “Browse,” browse to the “C:\Program Files (x86)\Java\jre[version]\bin” folder on your computer and double-click the “Javaws.exe” program file.


2 Answers

I have been able to do this & use it in production.

write a simple bootstrap class, jar it, and Launch4j the jar.

here's the main for the simple bootstrap class:

public static void main(String[] args) {
  try {     
    final File jnlp = File.createTempFile("temp", ".jnlp");
    final URL url = new URL("http://yourjnlp-wherever-youre-hostingit.jnlp");
    yourCopyStreamMethodYouWrote(url.openStream(),new FileOutputStream(jnlp));
    Desktop.getDesktop().open(jnlp);
  } catch (final Throwable t) { 
     // do something useful here
  }
}
like image 120
niceguy Avatar answered Sep 18 '22 04:09

niceguy


I've run into the same problem. I ended up with a BAT, a Shell and eventual a DMG for Macs.

I found this comment on automaded JRE installation for Windows using Nullsoft installer:

http://nsis.sourceforge.net/Java_Launcher_with_automatic_JRE_installation

I think outside JNLP you will find hard to get automation for all platforms. However on my project, up for two year, I haven't seen complains about users having to get java by themselves. I believe most machines will have it already. Windows user complained about not having a shortcut, but that is easy to do using vbs.

Also on the Mac DMG AppBundle, their is way to specify the JRE. Mac will have the lastest version, unless the are older PowerPC based machines. In that case no Java6.

Of you end up with several launcher, I would recommend an automated update strategy.

like image 26
Thomas Avatar answered Sep 19 '22 04:09

Thomas