1. Download the JavaFX SDK from the official Oracle or OpenJFX website.
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
[Link],[Link],[Link],[Link],[Link],[Link],[Link] \"${file}\" &&
java -cp \"${file_path}\" --module-path %PATH_TO_JAVAFX% --add-modules
[Link],[Link],[Link],[Link],[Link],[Link],[Link] \"$
{file_base_name}\"",
"file_regex": "^(..[^:]):([0-9]+):?([0-9]+)?:? (.)$",
"working_dir": "${file_path}",
"selector": "[Link]",
"variants":
"name": "Compile",
"shell_cmd": "javac --module-path %PATH_TO_JAVAFX% --add-modules
[Link],[Link],[Link],[Link],[Link],[Link],[Link] \"${file}\""
},
{
"name": "Run",
"shell_cmd": "java -cp \"${file_path}\" --module-path %PATH_TO_JAVAFX% --add-modules
[Link],[Link],[Link],[Link],[Link],[Link],[Link] \"$
{file_base_name}\""
d. Instead of %PATH_TO_JAVAFX% write the path to JavaFX. In my case it is \"C:\\tools\\
javafx-sdk-[Link]\"
e. Save the file as -> [Link]-build.
f. Tools -> Build System -> Choose MyJavaFX.
3. Build the simple app to test it and save it:
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class SimpleJavaFXApp extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
// Create a button
Button btn = new Button();
[Link]("Click me");
// Set action on button click
[Link](e -> [Link]("Button Clicked!"));
// Add button to a layout
StackPane root = new StackPane();
[Link]().add(btn);
// Create a scene
Scene scene = new Scene(root, 300, 250);
// Set the scene to the stage and show it
[Link]("Simple JavaFX App");
[Link](scene);
[Link]();
}
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-[Link]\lib" --add-modules
[Link],[Link] *.java
java --module-path "C:\tools\javafx-sdk-[Link]\lib" --add-modules
[Link],[Link] %1
Write your own path to javaFX folder.
Don’t forget to add \lib
c. Save as -> [Link] (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>