3

I have an application that I wrote, using JavaFX, that runs normally on Windows and Linux. On OSX, however, the application starts (is listed in the process list), but the GUI never appears. It is launched from another application that ensures that it is up to date, using the standard convention of "java -cp <all of the required libraries, including the jfxrt.jar> <main-class> <args>"

Is there something I'm missing that OSX needs to make JavaFX work correctly?

smbarbour
  • 352
  • 3
  • 13
  • What does `java -version` return? – jewelsea Feb 12 '14 at 20:50
  • I don't have an OSX machine myself, but I ensure that at least Java 7 is being used. No errors are being sent to STDERR either. Every OSX user has the same issue though. – smbarbour Feb 12 '14 at 20:55
  • possible duplicate of [compile javafx 2.0 manually](http://stackoverflow.com/questions/9436219/compile-javafx-2-0-manually) – jewelsea Feb 12 '14 at 22:42
  • It is compiled correctly, and does run on Windows and Linux without issue, but on OSX, it just does not show the GUI. This is the command-line used to launch it on my own computer (normally done via the other application that keeps it up to date): https://gist.github.com/smbarbour/8966694 – smbarbour Feb 12 '14 at 23:24

1 Answers1

1

The command line smbarbour used to run the application includes a jfxrt.jar location of:

/usr/lib/jvm/java-7-oracle/jre/lib/jfxrt.jar

As mentioned in EulerGeek's answer to Compile code using JavaFX 2.0 (using command line), on OS X, this location needs to be:

java -cp ".:/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/jre/lib/jfxrt.jar" <app class>

Replace jdk1.7.0_09.jdk with whatever version of java is installed on the machine, or require Java 8 when it is released (which does not require jfxrt.jar to be manually added to the classpath).

Deployment Recommendation

If you are deploying applications to users, even with Java 8, it is recommended that you package applications using relevant packaging tools (e.g. JavaFX ant tasks, javafxpackager, javafx-maven-plugin or javafx-gradle-plugin).

Community
  • 1
  • 1
jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • Sadly, I had already tried these suggestions without any success. – smbarbour Feb 13 '14 at 00:07
  • This is the console output from a user who is experiencing the issue of the GUI not appearing: http://pastebin.com/vMT5xguK The very long final line is the array of arguments used to launch. It does not contain quotes, but if it were run from the terminal, it would need them. – smbarbour Feb 13 '14 at 23:09
  • The console output doesn't really help, nothing there tells you why the GUI did not appear, there is no error message or stack trace to help trouble shoot the issue. The issue is something specific to your application as I have run many JavaFX applications on OS X without issue. – jewelsea Feb 14 '14 at 01:23
  • 1
    Strangely enough, it works without change or issue on OSX if using Java 8. I'll just recommend Java 8 for OSX users. – smbarbour Feb 14 '14 at 18:40