Adding build system in Sublime-Text, to Compile and Run JavaFX codes

What I assumed to be an issue with Sublime-Text turns out to be Java issue only, which could have been resolved quickly with few Google searches if I had thought about that.

So, thanks to some enlightenment from this Stackoverflow thread and mostly hit and trial, I was able to build successfully inside Sublime Text only without any added plugin or modification to Sublime Text.

This is how my build file looks now


    {
        "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}\"",
        "file_regex": "^(..[^:]):([0-9]+):?([0-9]+)?:? (.)$",
        "working_dir": "${file_path}",
        "selector": "source.java",
    
        "variants":
        [
            {
                "name": "Compile",
                "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}\""
            },
            {
                "name": "Run",
                "shell_cmd": "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}\""
            }
        ]
    }

Still can’t find an easy way to get Environment Variable working, so have to add complete for path in place of %PATH_TO_JAVAFX%.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top