Search code examples
javanetbeans

running a desktop application from another java application


With the help of Netbeans, I made a Java desktop application. I just made another class in that package where I just added a button. I meant it for the purpose of running Java desktop application which I made earlier. When searched for the main method of appview.java (only this contains a main) there was code like this:

public static void main(String[] args) {
    launch(SRECOApp.class, args);
}

I tried to put launch(SRECOApp.class, args); in the action listener of the button, but it didn't work. Please, what should I do now?


Solution

  • This is what the Desktop class and the Runtime class are meant for.

    Desktop class is more to open an application associated to a file (via its file extension).

    Runtime class is more to open an application and passing parameters to this application.

    Eg:

    Runtime.getRuntime().exec("notepad.exe")