Why is my Java Desktop Application Failing to Run?


Question

I have a Java Desktop Application with JavaFX 2 which I built and then I tried to run the JAR. The run failed so I ran it through the Command Line to get the errors. Here is what I got:

Edit: I updated the stack trace as some lines of code have been added/removed (The error is the same)

C:\Users\user\Desktop>java -jar DesktopApp.jar
Error: failed to msvcr100.dll java.lang.UnsatisfiedLinkError: Can't load library: C:\Users\user\Desktop\bin\msvcr100.dll
*** Fallback to Prism SW pipeline
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: Can't load library: C:\Users\user\Desktop\bin\mat.dll
        at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:252)
        at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:30)
        at javafx.embed.swing.JFXPanel.initFx(JFXPanel.java:128)
        at javafx.embed.swing.JFXPanel.<init>(JFXPanel.java:138)
        at app.Main.<clinit>(Main.java:150)
Caused by: java.lang.UnsatisfiedLinkError: Can't load library: C:\Users\user\Desktop\bin\mat.dll
        at java.lang.ClassLoader.loadLibrary(Unknown Source)
        at java.lang.Runtime.load0(Unknown Source)
        at java.lang.System.load(Unknown Source)
        at com.sun.glass.utils.NativeLibLoader.loadLibraryFullPath(NativeLibLoader.java:155)
        at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:85)
        at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:30)
        at com.sun.glass.ui.Application$1.run(Application.java:27)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.glass.ui.Application.loadNativeLibrary(Application.java:25)
        at com.sun.glass.ui.win.WinApplication.<clinit>(WinApplication.java:33)
        at com.sun.glass.ui.win.WinPlatformFactory.createApplication(WinPlatformFactory.java:20)
        at com.sun.glass.ui.win.WinPlatformFactory.createApplication(WinPlatformFactory.java:17)
        at com.sun.glass.ui.Application.Run(Application.java:49)
        at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:242)
        ... 4 more
Could not find the main class: app.Main. Program will exit.

Edit: Line 150 in Main.java is public static JFXPanel javafxPanel = new JFXPanel. It appears that FX is requiring mat.dll and it is looking in the wrong place for it so it can't find it. I am running the program on a Vista (32bit) but when I run on Windows 7 (64bit) the first line (below) is not there.

Error: failed to msvcr100.dll java.lang.UnsatisfiedLinkError: Can't load library: C:\Users\user\Desktop\bin\msvcr100.dll

After More Research:

After some internet research I found the below similar discussions which I am still studying:

It looks like msvcr100.dll and mat.dll are related to the JavaFX Runtime. I have the JavaFX Netbeans Plugin but I did not have the runtime. I now have it but that did not fix or change the problem. I found msvcr100.dll and mat.dll in ....netbeans\7.0\lib\javafx2-win\bin\ and also (after I installed the runtime) in C:\Program Files\Oracle\JavaFX Runtime 2.0\bin. It appears that my program is looking in the right place when run with Netbeans.


This is not the first time I ran this program. In past tries it was successful. Running through Netbeans does not produce any errors and the program runs properly.

Could this be an FX bug? How do I get my program to look in the right place and why is it not?

1
4
7/27/2011 7:14:17 PM

Accepted Answer

After even more research I decided to copy the bin folder located in *....netbeans\7.0\lib\javafx2-win* and also (after I installed the runtime) in *C:\Program Files\Oracle\JavaFX Runtime 2.0* to where my JAR is located.

This Worked! I guess the DLLs in the bin folder are required for JavaFX. Not sure why they would not automatically be included.

1
8/1/2011 1:20:58 PM

I had the same problem but this is how I solved it. Under Windows, I created a batch file with the following lines

call c:\bkn-batfiles\setclasspath.bat 
set
java -jar  E:\DATA\JAVACLASSES-NETBEANS\search_files_with_java_fx\dist\search_files.jar 
pause 

It runs great. In setcalsspath.bat I set the PATH as follows

SET PATH=.;C:\bkn-batfiles;
SET PATH=%PATH%c:\Program Files\java\jdk1.7.0_03\bin;
SET PATH=%PATH%c:\Program Files\java\jdk1.7.0_03\lib;
SET PATH=%PATH%C:\Program Files\Oracle\JavaFX 2.0 SDK\rt\bin;

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