Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX on mac install not found

Tags:

javafx

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:

http://www.oracle.com/technetwork/java/javafx/downloads/index.html

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?

like image 656
BAR Avatar asked Feb 16 '13 22:02

BAR


People also ask

How do I install JavaFX on Mac?

Download the latest JavaFX SDK installer file for Windows (an EXE extension) or Mac OS X (a DMG extension). Download older versions of the JavaFX SDK installer from the Previous Releases download page. After the download is complete, double-click the EXE or DMG file to run the installer.

Does JavaFX work on M1 Mac?

JavaFX 17.0. 2+ with support for M1 macs (aarch64 architecture) is available at the resources I linked in this answer.

Does JDK 17 support JavaFX?

JavaFX is not included in the JDK since Java 9 (with the exception of the Azul JDK, IIRC).

Does JDK 11 include JavaFX?

For JDK 11 and later releases, Oracle has open sourced JavaFX. You can find more information at OpenJFX project.


2 Answers

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
like image 137
jewelsea Avatar answered Sep 22 '22 01:09

jewelsea


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"/>
</path>

<target name="compile"
    description="Compiles the source code.">
    <mkdir dir="${classes.dir}"/>
    <javac includeantruntime="false"
        srcdir="${src.dir}" 
        destdir="${classes.dir}">
        <classpath refid="project.class.path"/>
        <exclude name="**/package-info.java"/>
    </javac>
</target>
like image 26
Bill Horvath Avatar answered Sep 21 '22 01:09

Bill Horvath