Make sure /jre/lib/jfxrt.jar is in your compilation path.
For example, for the 64-bit version of jdk7u6 on win7, here is jfxrt.jar:
C:\Program Files\Java\jdk1.7.0_06\jre\lib\jfxrt.jar
jfxrt.jar was stopped for the java runtime path for jdk1.7.0_06 until further validation between JavaFX and the rest of the java infrastructure is complete. This means that non-JavaFX related programs cannot be affected by the possible compatibility issues that JavaFX may cause. To date, I have never encountered any compatibility issue - it was just a cautious step by Oracle in this regard, I believe.
In a future version, jfxrt.jar should be added to the compilation path and default runtime for Java, and some of the information below should be out of date. You can track the request to add jfxrt.jar to the standard java runtime .
Compiling and running JavaFX from the command line
Below is an example for a JavaFX application class named javafxsamples.AudioPlaylist
If you are compiling from the command line, compile with:
javac -cp ".;C:\Program Files\Java\jdk1.7.0_06\jre\lib\jfxrt.jar" javafxsamples/AudioPlaylist.java
To start from the command line, you can use:
java -cp ".;C:\Program Files\Java\jdk1.7.0_06\jre\lib\jfxrt.jar" javafxsamples.AudioPlaylist
However, it is recommended that you package your applications using javafxpackager rather than manually adding jfxrt.jar to your class path (javafxpackager packaged applications will inject a launcher that finds jfxrt.jar and adds it to the class path).
javafxpackager -createjar -nocss2bin -appclass javafxsamples.AudioPlaylist -srcdir . -outfile AudioPlaylist.jar
After that, you can start the application without specifying the location of jfxrt.jar in the classpath:
java -jar AudioPlaylist.jar
Compiling and running a JavaFX program using the IDE
Netbeans
If you are using NetBeans 7.2+, you can create a JavaFX project type and it should automatically find JavaFX jfxrt.jar and put it in its path to the project class when you set jdk1.7.0_07 as yours.
Eclipse
If you are using an e (fx) clip , be sure to use the latest version (0.0.14+), which has the best features for detecting JavaFX.
Idea
Intellij Idea 11.1.3 will automatically add all the files from the jre lib directory to its path to the project class, so you should not compile errors with this. Note that Idea’s behavior is erroneous in this regard, it shouldn’t actually do this, but in the end you will get the expected behavior to compile and run your JavaFX classes from the idea.
Creating a JavaFX Program Using maven
- Make jfxrt.jar a system dependency for your maven project to get it in the way.
- Use maven antrunner to complete javafx ant deployment tasks.
An example of JavaFX packaging with maven is presented in this maven project .
Even if you use the IDE or Maven for your build, it is still recommended that you package the delivery application using the javafx ant or javafxpackager tasks, as this should provide the most reliable deployment solutions for your application.