Instructions JavaFX
Instructions JavaFX
Unzip it to a
convenient location on your computer, for example.
a.
b. Please make sure that it’s not within the ZIP package.
2. Create new build system.
a. Open SublimeText
b. “Tools” -> Build System -> New Build System
c. Paste: {
"shell_cmd": "javac --module-path %PATH_TO_JAVAFX% --add-modules
javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web \"${file}\" &&
java -cp \"${file_path}\" --module-path %PATH_TO_JAVAFX% --add-modules
javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web \"$
{file_base_name}\"",
"working_dir": "${file_path}",
"selector": "source.java",
"variants":
"name": "Compile",
},
{
"name": "Run",
@Override
public void start(Stage primaryStage) {
// Create a button
Button btn = new Button();
btn.setText("Click me");
// Create a scene
Scene scene = new Scene(root, 300, 250);
4. Now to easily run any new JavaFX app that you created, you need to do the last step:
a. Open new text file or just click to New File in Sublime text (Ctrl + N).
b. Paste this code:
@echo off
javac --module-path "C:\tools\javafx-sdk-19.0.2.1\lib" --add-modules
javafx.controls,javafx.fxml *.java
java --module-path "C:\tools\javafx-sdk-19.0.2.1\lib" --add-modules
javafx.controls,javafx.fxml %1
Write your own path to javaFX folder.
Don’t forget to add \lib
c. Save as -> runfx.bat (Note that it’s .bat format file). Save it where your projects are
located. For example:
d. Now write in such pattern: <bat file name> <class name>. When you will run it you
will see that it’s all running other classes, but you only have to worry about the your
class that you write after <bat file name>