javajavafxnotepad++nppexec

How to run JavaFX application from Notepad++? (Only runs as .jar file)


How do you correctly run a JavaFX Application from cmd Notepad++'s plug-in, NppExec? I previously used the command java $(NAME_PART) on the Notepad++ plugin NppExec (which is basically a built-in cmd) to run java which worked fine for swing-based programs. However, when I use that command to run a JavaFX Application, my Notepad++ window seems to lose focus as if a new window was opened but nothing appears.

EDIT: I discovered the problem lies in the Notepad++ plugin NppExec after testing the same command from the cmd. NppExec doesn't seem to function the same as the cmd when running JavaFX Applications.

The code I am using to test (which was originally obtained from http://docs.oracle.com/javase/8/javafx/api/javafx/application/Application.html) will be updated according to the edits above:

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;

public class MyApp extends Application {
    public void start(Stage stage) {
        Circle circ = new Circle(40, 40, 30);
        Group root = new Group(circ);
        Scene scene = new Scene(root, 400, 300);

        stage.setTitle("My JavaFX Application");
        stage.setScene(scene);
        stage.show();
    }
    //not required but recommended
    public static void main(String[] args) {
        launch(args);
    }
}

Solution

  • Answering my own question.

    From NppExec's manual,

    - NppExec is not a command interpreter. NppExec does not understand such commands as 'copy', 'call', 'for' and so on because it is neither a "real" console nor a console emulator. However, NppExec has its own internal implementation of such commands as 'cls', 'cd', 'dir', 'echo', 'set' ('env_set') and introduces other, specific, commands. Also you can use "cmd /c <command>" to execute any cmd's command inside NppExec.

    Using cmd /c java $(NAME_PART) rather than java $(NAME_PART) to run successfully worked.

    Still unsure why simply calling java $(NAME_PART) works for non-JavaFX programs but fails for JavaFX programs but I don't think the issue belongs here.