JavaFX on mac install not found


So I am trying to run a simple helloworld app for the javafx but its packages cannot be found. Ok so must be some kind of path issue right?

I have downloaded the co-bundled version from here:

You would expect that a co-bundled would install just as the SE package installed. I have searched the net and people give windows answers with windows path's to a mac problem. Which is really IMO a java problem because either you co-bundle like you said you did and install both or keep them separate!

I have yet to find an appropriate solution to getting javafx to be included in the compile, that does not involve including long paths.

EDIT: After installing netbeans and creating a javafx project, it had no trouble locating the appropriate packages. I think at this point it should be clear that FX is co-bundled with the SE version however they ( java maintainers ) have decided to make it decidedly uneasy to get FX working from the command line. Any insight into this otherwise dumb decision?

2/16/2013 10:55:28 PM

Accepted Answer

Some choices:

  1. Use JavaFX 8 which places JavaFX is on the default runtime classpath.
  2. Package your application with the Oracle JavaFX deployment tools that will insert code in your app to find JavaFX.
  3. Manually add the path to jfxrt.jar to your your compile and runtime classpath if you cannot do either of the above.

For 3 you can find jfxrt.jar for the jre under:

/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

If you have jdk7 installed, you can run a JavaFX app (packaged using the JavaFX deployment tools) from the command line using something like the following:

export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
java -version
java -jar application.jar

If it is just the JRE7 installed and no JDK, then you can use:

/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -jar application.jar
2/17/2013 12:32:20 AM

Per option #3 in Jewelsea's answer, here's how it looked in my ant build file:

<property name="jfx.dir" value="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib"/>

<path id="project.class.path">
    <pathelement path="${classpath}"/>
    <pathelement location="${jfx.dir}/jfxrt.jar"/>

<target name="compile"
    description="Compiles the source code.">
    <mkdir dir="${classes.dir}"/>
    <javac includeantruntime="false"
        <classpath refid="project.class.path"/>
        <exclude name="**/"/>

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