Javafx application does not run on some computers after exported to jar

Asked

Viewed 1,336 times

7

I developed a Javafx application, created an Ant script through build.fxbuild and ran a jar.

The generated jar runs Ok on the computer on my service and on another developer’s computer, however it doesn’t run on two non-developer computers, it also doesn’t run on two virtual machines that I have on my pc and as amazing as it seems it doesn’t run on my home computer, developer. All OS I tried are Windows (none was 7 Home Basic), I don’t believe the problem is related to OS.

When I spin the jar I see a window:

Javafx Launcher Error
Exception while running Application

How the image shows:

enter image description here

Running the jar through the command prompt using java -jar meuprojeto.jar i get the following stack trace:

java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.javafx.main.Main.launchApp(Main.java:642)
        at com.javafx.main.Main.main(Main.java:805)
Caused by: java.lang.RuntimeException: Application launch error
        at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:122)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: com.sun.glass.ui.win.WinApplication._
invokeLater(Ljava/lang/Runnable;)V
        at com.sun.glass.ui.win.WinApplication._invokeLater(Native Method)
        at com.sun.glass.ui.Application.invokeLater(Application.java:338)
        at com.sun.javafx.tk.quantum.QuantumToolkit.defer(QuantumToolkit.java:62
0)
        at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:17
3)
        at com.sun.javafx.application.PlatformImpl.runAndWait(PlatformImpl.java:
212)
        at com.sun.javafx.application.PlatformImpl.tkExit(PlatformImpl.java:320)

        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherIm
pl.java:421)
        at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:
47)
        at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
        ... 1 more

I have other Javafx applications with far fewer dependencies that run normally on these computers.

I already checked the variables of the PATH system and everything seems to be ok.

I used Maven to get all the dependencies correctly (I believe), but unfortunately I had to desMavenizar my project then because I had problems deploying through it, for being a project in Javafx. But I kept the dependencies he brought me, and I cared in the proper way.

Trying to understand this mistake that says nothing of anything I found a question that could have helped me if I had a decent answer:

Javafx on Windowsxp Error

The mediocre solution proposed by the author himself does not seem appropriate, however it made me think that some dependence is missing in my jar that was generated.

How do I find out what the problem is if the only tip I have is this mysterious stack trace? And how to solve?

I don’t intend to use the Javafx Maven Plugin, I had some bad experiences with him and I think I’ll solve my problem for Ant much more easily.

  • Just one question: Javafx 2.x or 8?

  • @Kyllopardiun 2.2 point something, if you need to know what the "something" is I can find out, but it will take a little while

  • I don’t need to. The only thing you should be careful about using Javafx 2.2 (i.e Java 7) is that jfxrt.jar library is not included by default. And this is often Javafx programmers forget this detail. Otherwise, there’s no helping you without knowing the content of the lines Main.java:642 and Main.java:805 although I suspect they are the call of the UI.

  • @Kyllopardiun with ctz the library was included. On the line of Main.java:642, it does not belong to my application but to Javafx itself, pay attention to the package: com.javafx.main.Main.launchApp. In the entire stack trace there is no reference to even a single line of a class developed by me, so I called him mysterious, he left me almost no hint.

  • 1

    @Kyllopardiun By the way, I’ve already managed to solve the problem, but it turns out I’ve done so much to try to solve that I don’t know exactly which one was the solution, I think it was the fact of upgrading jdk from u25 to u45, but I’m not sure, I need some time to run some tests and find out. And more than that, I would like to know what exactly of my application makes the mistake, because in another application of mine I had no problems. I also have to test the solution suggested by the answer below. I only know that there are several possibilities, rsrs..

2 answers

1

Try exporting normally as 'runnable jar file' by checking the following option:

It is likely that the packaging of dependencies is implicating the execution, leaving OS responsibility to find some libs.

  • Do you mean that because dependencies are in jar format instead of classes in folders may imply some problem to find dependencies?

  • Yes, for executable jar’s it is interesting to have inside the jar the dependencies organized in folders. Normally, a JAR file inside a JAR file cannot be loaded by the JVM. This way Eclipse adds special classes in the executable JAR to make this possible.

  • As I have been making some radical changes to my project I will have to recreate the conditions of the above error and test, I will ask you for a little patience while not doing this. Anyway thanks for the help already.

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.