How to deploy a desktop JavaFx 2.0 application correctly using jnlp for 32 and 64 bit? - deployment

I have a jnlp file for deploying my javafx 2.0 application, however, how do I make sure that the users have the correct javafx runtime (32 or 64 bit depending on the jvm present on the machine) and if not, download it and run the application.
Assuming that the user does not have a javafx runtime currently installed, the problems that I'm facing mostly with a 64 bit machine with either 32-bit, 64-bit or both JRE's are:
1) The Javafx swing deployment guide mentions to use the <jfx:javafx-runtime version /> tag to download the appropriate jfx runtime, but JRE below 1.7 doesn't understand this tag/namespace.
2) If a 32-bit jre is installed on a 64-bit machine, then how do I install my application to the "Program Files(x86)" folder, download and use 32-bit javafx runtime.
3) If a 64-bit jre is installed on a 64-bit machine, then how do I install my application to the "Program Files" folder, download and use 64-bit javafx runtime.
Here is how my jnlp file looks currently:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="file:///C%3A/Program%20Files/HP/Pulse/PulseLite"href="iMonLauncher.jnlp">
<information>
<title>iMonLauncher</title>
<vendor>Administrator</vendor>
<homepage href="file:///C%3A/Program%20Files/HP/Pulse/PulseLite"/>
<description>iMonLauncher</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
<jar href="iMon.jar" size="428419"/>
<jar href="lib/ibase-core.jar" size="197029"/>
<jar href="lib/ibase-fx.jar" size="210175"/>
<jar href="lib/imonDB.jar" main="true" size="156616"/>
<jar href="lib/imon-service.jar" main="true" size="73190"/>
</resources>
<application-desc name="iMon" main-class="imon.Main" >
</application-desc>
<update check="always"/>
The codebase changes automatically, to point to the correct program files folder depending on the architecture.
Thanks in advance !

You miss xmlns:jfx namespace in your jnlp. It should starts with
<jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="iMonLauncher.jnlp">
Once user has regular java installed and clicked on such jnlp file he would be presented with automatic download message for FX. It will find out which java is used, download and install approprivate javafx version.

Related

No show anymore message of publisher Java Web Start

I have developed an application via Java Web Start more or less according to this: How do I fix "missing Codebase, Permissions, and Application-Name manifest attribute" in my JNLP app? I have packed the jar with manifest.txt, etc..but in this way I have resolved missing attributes problem, and now I have other problem this message is always showed!! I checked "No show again" and each time I press button to execute and always is showed!! I
Adicionally this is my manifest file:
Manifest-Version: 1.0
Class-Path: .
Main-Class: com.zkteco.biometric.AccesoBiometrioAS2
Permissions: all-permissions
Codebase: http://192.168.111.25:8180/pos-web/
Application-Name: Biometrico
And my Jnlp File this:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://192.168.111.25:8180/pos-web/">
<information> <title>CajaPos</title> <vendor>xxx</vendor>
</information>
<security><all-permissions/>
</security>
<resources>
<j2se version="1.2+"/>
<jar href="xx.jar"
main="true" />
</resources
<application-desc main-class="ec.com.xx.pos" type="JavaFX">
<argument>XY</argument>
</application-desc>
</jnlp>
In this page after check the dialog is not showed again and works fine.
https://docs.oracle.com/javase/tutorial/deployment/webstart/deploying.html
Where XY change for each request because I generate jnlp-xml in a dynamically way with a servlet.
This is due to your Java settings. It is a security prompt. There’s nothing you can change in your application to prevent this dialog, it is up to the end-user to change their security settings to show/hide these dialog windows.
Edit: I also recommend migrating your app to a different delivery platform because Java Web Start is being violently turned off by Oracle.

How to add libraries to Wildfly Application Server using module?

I want to load the Application server Libraries in Java Build Path in Eclipse,
I have 5 applications in Eclipse which shares common libraries,
I can't put all the libraries in each project lib folder,
so i want to add the libraries in Wildfly Application server using modules.
This is my module.xml file add added the lib at WILDFLY_HOME/modules/system/layers/base/com/mysql/main/mysql-connector-java-5.1.23-bin.jar
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.23-bin.jar" />
</resources>
<dependencies>
<module name="javax.api" />
<module name="javax.transaction.api" />
</dependencies>
</module>
After Restarting the server, this module is not loading in Eclipse Build path.
Can any one knows what wrong with this modules ?
In Wildfly I have some predefined modules, those are loading in build path successfully, but user-defined modules are not loading ?
Why ?
Solution found:
Follow below steps :
Go To Eclipse > preferences > Server > Runtime Environments > Default Classpath Entries
Select "Wildfly 8.x Runtime" and add a module
and click on apply, now rebuild your application and check,
the library will be added in buildpath by module name.

deploying OSGi project as Webstart using command line tools

How do I create a modular OSGi project that can be distributed with Java Webstart, using command line tools?
I've found instructions to export a set of OSGi plugins from eclipse. But instructions for doing so without the help of eclipse are hard to find. I would like to do this using ant build scripts and / or other command line tools.
Here is what I've got so far. Using ant, all the plug-in bundles are copied to a directory and signed. After that, I've created a jnlp file named wrapper.jnlp
<?xml version="1.0" encoding="UTF-8"?>
<jnlp codebase="http://localhost/webstart" href="wrapper.jnlp">
<information>
<title>My app</title>
<vendor>Me</vendor>
<offline-allowed/>
</information>
<resources>
<j2se version="1.5+" java-vm-args="-Xmx512M"/>
<jar href="org.eclipse.equinox.launcher.jar"/>
<extension name="Wrapper feature" href="myprogram.jnlp"/>
</resources>
<application-desc main-class="org.eclipse.equinox.launcher.WebStartMain"/>
<security>
<all-permissions/>
</security>
</jnlp>
I've created a second jnlp file named myprogram.jnlp.
<?xml version="1.0" encoding="UTF-8"?>
<jnlp codebase="http://localhost/webstart" href="myprogram.jnlp">
<information>
<title>My app</title>
<offline-allowed/>
</information>
<resources>
<j2se version="1.5+" java-vm-args="-Xmx512M"/>
<jar href="myapp.jar"/>
<jar href="derby.jar"/>
<jar href="commons-math-2.0.jar"/>
...omitting a dozen more jar files...
</resources>
<application-desc main-class="myprogram.Main"/>
<security>
<all-permissions/>
</security>
</jnlp>
When I deploy and try to start it (from the command line: javaws http://localhost/webstart/wrapper.jnlp), the jar files of the application appear to be downloaded. Then I get the following error in a log file:
!SESSION Wed Jun 29 13:43:52 CEST 2011 -----------------------------------------
!ENTRY org.eclipse.equinox.launcher 4 0 2011-06-29 13:43:52.448
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:411)
at org.eclipse.equinox.launcher.WebStartMain.basicRun(WebStartMain.java:78)
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
at org.eclipse.equinox.launcher.WebStartMain.main(WebStartMain.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at net.sourceforge.jnlp.Launcher.launchApplication(Launcher.java:590)
at net.sourceforge.jnlp.Launcher$TgThread.run(Launcher.java:887)
Any idea what I'm doing wrong? Where should I look next?
I had the same issue. I solved it by specifying the following in my wrapper jnlp:
<resources>
<!-- Reference to the launcher jar. The version segment must be updated to the version being used-->
<jar href="plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar" />
<!-- Reference to the osgi jar. The version segment must be updated to the version being used-->
<jar href="plugins/org.eclipse.osgi_3.7.0.v20110613.jar" />
...
</resources>
I believe you might want to switch gears and create a P2 repository with your code and all dependencies, then have a bare-bones p2-installer pull the dependencies from there (bypassing WebStart) and start your application.
Have a look at this http://www.jbundle.org/osgi-webstart/ "Use this servlet to deploy your OSGi apps to a web client."
Though it's a maven plugin from the documentation it looks like you can run it without a maven project.
According to the sources, your problem is caused by failing to find org.eclipse.osgi bundle on the classpath. Make sure that the bundle is referenced properly and that it has correct manifest.

Java Webstart with Tibco Native Libs

I am trying to deploy an application that uses the native implementation of Tibrv through the TibrvJ library using Java Webstart.
I have packaged up all of the Windows dlls from inside c:\tibco\tibrv\bin into a Jar file and have added these to the nativelib element in the JNLP file.
I was hoping that webstart would take the dll files from thetibco-7.5.1-nativelibs.jar file and allow them to be loaded via System.loadLibrary which is called from Tibrv.open(). However it doesn't seem to want to work properly.
My JNLP file looks like this:
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc//DTD JNLP Descriptor 6.0//EN" "http://java.sun.com/dtd/JNLP-6.0.dtd">
<jnlp spec="6.0+"
codebase="http://somewhere:8080/my-gui/application"
href="launch.jnlp">
<information>
<title>My GUI</title>
<vendor>Technology</vendor>
<description>Dashboard</description>
<description kind="short">Dashboard</description>
<icon href="icon/Stocks-128x128.png" />
<offline-allowed />
<shortcut online="true">
<desktop />
<menu submenu="Dashboard" />
</shortcut>
</information>
<security>
<all-permissions />
</security>
<update check="always" policy="prompt-update" />
<resources>
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"
java-vm-args="-Xmx120M -ea />
<property name="log4j.configuration" value="live/log4j.xml" />
<property name="swing.aatext" value="true" />
<jar href="tibrvj-7.5.1.jar" />
<jar href="dashboard-gui.jar" main="true" />
</resources>
<resources>
<nativelib href="nativelib/tibco-7.5.1-nativelibs.jar" />
</resources>
<application-desc main-class="com.somewhere.Main">
<argument>classpath:/live/client.xml</argument>
<argument>/live/live.properties</argument>
</application-desc>
</jnlp>
The application launches but as soon as a call is made to open tib then it falls apart with an error along the lines of:
[Root exception is TibrvException[error=22,message=Version mismatch: libtibrv version 7.4 does not match version of tibrvj shared library 7.5]]
TibrvException[error=901,message=Library not found: tibrvj]]
The users have a variety of Tib installations already on their PCs from Tib 7.2 through to 7.5. The Webstart Application only works correctly on a machine with 7.5 installed which matches the Jar file inside the package. So it doesn't appear to do anything with the nativelib jar.
I would like to avoid having to deploy 3 versions of the web start application for the different versions of Tib that the users have installed.
Has anyone else managed to get this combination of TibrvJ and Webstart working?
I've managed to get it working. The trouble is that the call to System.loadLibrary when using Webstart doesn't load in the dependencies of the specified library even if they have been packaged up into a nativelib jar.
See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6191612 for more info.
To get around this problem it is necessary to explicity load all of the dependencies in the correct order. It is also necessary to put each dll library into its own jar file.
So to use native TibrvJ you need to make the following calls before any calls to Tibrv.Open.
System.loadLibrary("msvcr71");
System.loadLibrary("tibrv");
System.loadLibrary("tibrvcm");
System.loadLibrary("tibrvft");
System.loadLibrary("tibrvcmq");
System.loadLibrary("tibrvj");
Happy Days!
I think you have encountered a problem with Webstart.
Some years ago, I had a Webstart application using Java 3D that didn't work on Macs. Eventually I found that all Macs some with an old version of Java 3D installed, and that already installed version was used over the newer version that I had included in the in my JNLP file. Your problem sounds almost exactly like this, so it could very well be the same problem.

why do I get UnsupportedClassVersionError in jnlp?

I get an UnsupportedClassVersionError thrown when launching jnlp, however when I try to run the relevant jar files from command line everything works fine. I tried setting j2se versions to 1.5+, 1.6+, using signed/unsigned jar files, but all that doesn't help.
I'm trying to launch my own jar file with two supporting jar files (mysql-connector.jar and swingx.jar). My jar file has been compiled with 1.6 compliance settings in Eclipse and built into a jar with ant. Since I can launch the 3 jars from command line using java 1.6 I'm a bit baffled that jnlp fails. Any help is appreciated.
Here is the jnlp file:
<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File -->
<jnlp spec="1.5+" codebase="http://www.etc.com/p" href="demo-daily.jnlp">
<information>
<title>demo: daily stock charting utility</title>
<offline-allowed/>
</information>
<security>
</security>
<resources>
<j2se href="http://java.sun.com/products/autodl/j2se" version="1.6+" />
<jar href="demo-daily.jar" main="true" />
<jar href="swingx.jar" main="false" />
<jar href="mysql-connector.jar" main="false" />
</resources>
<application-desc main-class="quipu.viewers.charts.stockcharts.daily"/>
</jnlp>
The error I get is:
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at com.sun.jnlp.JNLPClassLoader.findClass(JNLPClassLoader.java:256)
at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1052)
at com.sun.javaws.Launcher.run(Launcher.java:105)
at java.lang.Thread.run(Thread.java:613)
First, open a CMD window or a shell window (as appropriate to the OS you're using) and type this:
java -version
to ensure that the version you're running is the version you expect to be running. Then, again from the command line, issue the command:
javaws http://host/path/to/your.jnlp
If you cannot run javaws from the command line, then you'll have to find out where it's installed and use the full path to the executable. Under Windows, this will be something like
C:\Program Files\Java\jre1.6.0_14\bin\javaws.exe
and under Linux it may be /usr/bin/javaws or it may be in another directory.
I know under Windows, at any rate, when you run any Java Web Start app, the JNLP loader is used from the most recent Java version installed. Or at least it's supposed to do this. I haven't experimented under Linux (or MacOS) to see how it works there. But it's always possible that something has gotten messed up and when you launch a JNLP you are accidentally running a Java 1.5 JNLP launcher.
You can always try to uninstall and re-install the most recent version of Java to ensure that the latest and greatest version is properly installed. This may fix things. You may also want to check your $PATH (or %PATH%) to ensure that the correct version of Java is on the path. (This is not always necessary ... but if any version of Java is on the path, ensure that it's the version you want.) Check the environment variable JAVA_HOME to make sure it points where you think it does.
Just a guess, but update the opening tag to reference spec="1.6+"
<jnlp spec="1.6+" codebase="http://www.etc.com/p" href="demo-daily.jnlp">