smbarbour
smbarbour

Reputation: 352

Is something special required to launch JavaFX applications on OSX?

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?

Upvotes: 3

Views: 1959

Answers (1)

jewelsea
jewelsea

Reputation: 159566

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).

Upvotes: 1

Related Questions