4 Replies Latest reply: Feb 13, 2013 1:52 AM by 988857 RSS

    Deployment of JavaFX Web application on client machine(Windows OS.)

      Problem Statement:

      Deployment of JavaFX Web application on client machine(Windows OS.)
      Error: unable to load the native libarary(JNI Windows dll) i.e. throws java.lang.UnsatisfiedLinkError exception.

      Problem Description:
      I have create the JavaFX application which have dependency on Native library written in Java Native Interface(JNI).
      When the application is deployed on Apache 6.0 Tomcat Server(Copied .html file *.jnlp file and .jar file) and when client machine hit the html page in internet explorer version 8.0 its throws the following error(java.lang.UnsatisfiedLinkError: no JNIHelloWorld in java.library.path)

      I have created the jar file which have my "JNIHelloWorld' native library dll in root directory. I have signed the jar with same signature which i have used for signing for my application Jar file.
      I have mentioned the native library jar in JNLP file resource keyword as follows:

      <resources os=Windows>
      <nativelib href="JNIHelloWorld.jar" download="eager" />

      The complete jnlp file content is in "JavaFXApplication.jnlp file:" section below.

      The description of error is as follows:

      Match: beginTraversal
      Match: digest selected JREDesc: JREDesc[version 1.6+, heap=-1--1, args=null, href=http://java.sun.com/products/autodl/j2se, sel=false, null, null], JREInfo: JREInfo for index 0:
      platform is: 1.7
      product is: 1.7.0_07
      location is: http://java.sun.com/products/autodl/j2se
      path is: C:\Program Files\Java\jre7\bin\javaw.exe
      args is: null
      native platform is: Windows, x86 [ x86, 32bit ]
      JavaFX runtime is: JavaFX 2.2.1 found at C:\Program Files\Java\jre7\
      enabled is: true
      registered is: true
      system is: true

           Match: ignoring maxHeap: -1
           Match: ignoring InitHeap: -1
           Match: digesting vmargs: null
           Match: digested vmargs: [JVMParameters: isSecure: true, args: ]
           Match: JVM args after accumulation: [JVMParameters: isSecure: true, args: ]
           Match: digest LaunchDesc:
           Match: digest properties: []
           Match: JVM args: [JVMParameters: isSecure: true, args: ]
           Match: endTraversal ..
           Match: JVM args final:
           Match: Running JREInfo Version match: ==
           *Match: Running JVM args match: have:<> satisfy want:<>*
      *java.lang.UnsatisfiedLinkError: no JNIHelloWorld in java.library.path*
      *     at java.lang.ClassLoader.loadLibrary(Unknown Source)*
      *     at java.lang.Runtime.loadLibrary0(Unknown Source)*
      *     at java.lang.System.loadLibrary(Unknown Source)*     at javafxapplication20.JavaFXApplication20.<clinit>(JavaFXApplication20.java:41)
           at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
           at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
           at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
           at java.lang.reflect.Constructor.newInstance(Unknown Source)
           at java.lang.Class.newInstance0(Unknown Source)
           at java.lang.Class.newInstance(Unknown Source)
           at com.sun.javafx.applet.FXApplet2.init(FXApplet2.java:63)
           at com.sun.deploy.uitoolkit.impl.fx.FXApplet2Adapter.init(FXApplet2Adapter.java:207)
           at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
           at java.lang.Thread.run(Unknown Source)
      Java Plug-in
      Using JRE version 1.7.0_07-b11 Java HotSpot(TM) Client VM
      User home directory = C:\Users\io839

      Please find my native library code and JavaFX application code:

      Native library JNI Code:

      JNIEXPORT jstring JNICALL Java_javafxapplication_SampleController_printString(JNIEnv *env, jobject envObject)
           string str = "hello JNI";
           jstring jniStr = env->NewStringUTF(str.c_str());
           return jniStr;

      JavaFX Application code:

      package javafxapplication;

      import javafx.application.Application;
      import javafx.fxml.FXMLLoader;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.stage.Stage;
      public class JavaFXApplication extends Application {

      public void start(Stage stage) throws Exception {
      Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml"));

      Scene scene = new Scene(root);


      * The main() method is ignored in correctly deployed JavaFX application.
      * main() serves only as fallback in case the application can not be
      * launched through deployment artifacts, e.g., in IDEs with limited FX
      * support. NetBeans ignores main().
      * @param args the command line arguments
      public static void main(String[] args) {

      SampleController.java file:

      package javafxapplication;

      import java.net.URL;
      import java.util.ResourceBundle;
      import javafx.event.ActionEvent;
      import javafx.fxml.FXML;
      import javafx.fxml.Initializable;
      import javafx.scene.control.Label;

      public class SampleController implements Initializable {

      private Label label;
      private native String printString();

      private void handleButtonAction(ActionEvent event) {
      System.out.println("You clicked me!");
      String str = printString();

      public void initialize(URL url, ResourceBundle rb) {
      // TODO
      //String str = printString();

      JavaFXApplication.jnlp file:

      <?xml version="1.0" encoding="utf-8"?>
      <jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="JavaFXApplication.jnlp">
      <description>Sample JavaFX 2.0 application.</description>
      <jfx:javafx-runtime version="2.2+" href="http://javadl.sun.com/webapps/download/GetFile/javafx-latest/windows-i586/javafx2.jnlp"/>
      <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
      <jar href="JavaFXApplication.jar" size="20918" download="eager" />
      <resources os=Windows>
      <nativelib href="JNIHelloWorld.jar" download="eager" />
      <applet-desc width="800" height="600" main-class="com.javafx.main.NoJavaFXFallback" name="JavaFXApplication" >
      <param name="requiredFXVersion" value="2.2+"/>
      <jfx:javafx-desc width="800" height="600" main-class="javafxapplication.JavaFXApplication" name="JavaFXApplication" />
      <update check="always"/>
        • 1. Re: Deployment of JavaFX Web application on client machine(Windows OS.)

          I'm not sure if this will fix the error, but from docs I see that you forgot the " sign around Windows.

          {code}<resources os=Windows>{code}
          should be..
          {code}<resources os="Windows">{code}

          Hope this fix the problem!

          Edited by: FXdude on 4-feb-2013 2:13

          Edited by: FXdude on 4-feb-2013 2:13
          • 2. Re: Deployment of JavaFX Web application on client machine(Windows OS.)
            Thanx for your input.
            I have tried with following suggestion also it does not work.
            <resources os="Windows">

            For deployment of application on client machine, shall i need to write installation script for that?
            • 3. Re: Deployment of JavaFX Web application on client machine(Windows OS.)
              No problem.
              Make sure your resources are set at the proper location. Could be that tje jni.jar is under a 'lib' folder?

              Normally you don't have to worry about deployment a lot if you are using like Netbeans 7.2 or higher.
              When you press 'Clean and build' it creates your deployed files in the 'dist' folder.

              You can change specification by adapting the build.xml file.
              Of course lot of different possibilities are available for deployment!

              You can find lot of info here:

              Important to know is if you want to work with
              - a standalone application (self-contained or not)
              - with webstart
              - or with applets

              (In my case I'm using webstart, but also Self-Contained Application Packaging (jre is also installed!)
              • 4. Re: Deployment of JavaFX Web application on client machine(Windows OS.)
                I have solved the problem.. I have done following steps to do it..

                - JNLP file needs to specify the OS name and achitecure like this
                +<resources os="Windows" arch="x86">     +
                +<nativelib href ="lib/myNative.jar" size="727093" download="eager" />+

                - I have put ant deployment script in build .xml as mentioned in oracle javaFX deployment article.

                - Needs to put all your native resources in project root folder e.g. OS_Name/arch/myNative.jar, build.xml ant script uses this location for native library lookup.

                Note: In Windows all native library is copied in user machine when JavaFX application is loaded in browser.
                The location is: C:\Users\UserloginID\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\

                So that call for native library System.loadLibrary() is resolved.