JavaFX and external JARs


I am trying to deploy JavaFX application, but when I run it in browser, it looks like it cannot find the classes in external jar files.

java.lang.RuntimeException: java.lang.ExceptionInInitializerError

Caused by: java.lang.ExceptionInInitializerError

I have common.jar in my lib folder and classpath. I also use unrestricted access in project properties. And I also know about this topic JavaFx 2.0 application referencing external jars, but it wont work for me. Everything works fine when I run it from Netbeans. But in browser it wont initialize classes in external jars. Could you please help me. Thank you

jnlp file is here

 <?xml version="1.0" encoding="utf-8"?>
    <jnlp spec="1.0" xmlns:jfx="" href="JavaFXSklad2.jnlp">
    <description>Sample JavaFX 2.0 application.</description>
    <resources os="Windows">
    <jfx:javafx-runtime version="2.0+" href=""/>
     <j2se version="1.6+" href=""/>
         <jar href="JavaFXSklad2.jar" size="164987" download="eager" />
         <jar href="lib/common.jar" size="965131" download="eager" />
        <jar href="lib/ifxjdbc.jar" size="705534" download="eager" />
        <jar href="lib/infra.jar" size="588915" download="eager" />
    <jar href="lib/jdawt.jar" size="726475" download="eager" />
    <jar href="lib/toplink.jar" size="1450414" download="eager" />
    <jar href="lib/weblogic.jar" size="55582010" download="eager" />
      <applet-desc  width="800" height="600" main-class="com.javafx.main.NoJavaFXFallback"  name="JavaFXSklad2" />
  <jfx:javafx-desc  width="800" height="600" main-class="md.MainMenu"  name="JavaFXSklad2" />
  <update check="background"/> 

Edit> Finally I realize, that the problem is caused by static block in class in jar on this line>

String osName= (String) System.getProperties().get("");

I also try to sign external jars and javafx jar with the same cetrificate, but without success.

5/23/2017 10:34:18 AM

If you are using NetBeans 7.1, you need to update your NetBeans to the latest nightly version

Earlier versions of NetBeans have a bug packaging jar files

You can see if your NetBeans generated package has this bug by unjarring your application's jar files and checking that it's META-INF/MANIFEST.MF file includes references to your external jar files.

It looks like the jars you are using (things like Toplink, jdbc and WebLogic) require security privileges above what you are available to an unsigned application, so you also need to request further security permissions as Sergey recommends and sign your application. To do this:

  1. Right click your project in NetBeans.
  2. Choose Build | Deployment
  3. Check Request Unrestricted Access.
  4. If you have a signing certificate from a CA, click the Edit... button next to signing certificate otherwise just accept the default NetBeans generated self-signed certificate.

Note that once you do this, users will now get Info and Alert boxes when they use your application because the application is requesting increased privileges over what a normal web page would have.

In Java, if static initialization of a class fails, the class load will fail to complete, even though the class is available and on the class path. This means that the first reference to the class will generate an ExceptionInInitializerError and subsequent references to the class will generate, an often misleading, ClassNotFoundException.

ExceptionInInitializerError is thrown to indicate that an exception occurred during evaluation of a static initializer or the initializer for a static variable. The Jar containing the class file throwing the error was found and loading of the class commenced but could not be completed because errors were experienced in it's static variables or constructor.

Suspect code would be TextAttributeProp.checkLimit(, although the root cause of your issue may be elsewhere. Check what the TextAttributeProp static code is doing, and wrap static initialization methods in try catch blocks to get more debugging info, take fallback action or ignore the static initialization error.

System.getProperties() will not return you the properties you want in an unsigned applet - it will just return null. You then try to dereference this null value in a static initializer which generates a NullPointerException and causes your class load to fail and subsequent references to the class to turn up ClassNotFoundException.

If you directly get the property "" via System.getProperty("") rather than getting all System properties, it works because "" is not marked as security sensitive. To see which properties you can and cannot request from an Applet, refer to: Also note that an unsigned applet cannot set any System properties.

If your application is properly signed, you should be able to get and set any System properties you want. If you cannot do this, then you can file a bug against the JavaFX browser plugin at First check that you have signed your app correctly by trying to do something else which requires elevated privileges, for example, read a file from your root file system from the signed applet and ensure that the read does not fail.

2/7/2012 8:02:39 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow