Java : Central Application
I'm currently developing multiple project management applications for my team, and distributing these as JARs, which is OK for now. But I was asked to make a central application to launch them.
Basically a small app, with a but开发者_高级运维ton for each app I already made, and when you click the button, it launches the corresponding app. I managed to do everything except one point. I include my JARs in the buildpath, then launch them by creating an instance of the Main class. This actually works, but when I want to close one window, it closes all of them....
Anyone got an idea on this ?
Thanks
You need to run the new application in a different VM by launching a new process. Something like this:
new ProcessBuilder("java", "-jar", "EXECUTABLE.JAR").start()
If Java is in your path.
Are launching using another Java app? If so, the window close event might trigger a System.exit(); Could you post some code?
Also consider using Webstart and providing the links to the applications in a web page. Thus users could open that page and Webstart would download and start the app.
Found it ! I had this in each app Main class (extending JFrame
) :
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
I changed it to :
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
Now this works.
Thanks for help
精彩评论