Home >Java >javaTutorial >How to Compile JavaFX Code using the Command Line in Java 7, 8 (Oracle and OpenJDK)?
To compile code using JavaFX from Windows, you must leverage the Java Compiler and specify the correct classpath.
Oracle Java 8 and Newer: JavaFX classes are included in the default runtime classpath, allowing you to compile and run code using:
javac Fxservidor.java java Fxservidor
OpenJDK 8: JavaFX sources require compilation and inclusion of the resultant jfxrt.jar in the classpath:
javac -classpath "$JAVAFX_SDK_HOME/rt/lib/jfxrt.jar" Fxservidor.java java -classpath "$JAVAFX_SDK_HOME/rt/lib/jfxrt.jar:." Fxservidor
For Java 7, the process is slightly different:
"%JDK_HOME%\bin\javac" -classpath "%JAVAFX_SDK_HOME%\rt\lib\jfxrt.jar" Fxservidor.java java -classpath "%JAVAFX_SDK_HOME%\rt\lib\jfxrt.jar;." Fxservidor
Tips:
<code class="java">import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class Fxservidor extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { </code>
The above is the detailed content of How to Compile JavaFX Code using the Command Line in Java 7, 8 (Oracle and OpenJDK)?. For more information, please follow other related articles on the PHP Chinese website!