简体   繁体   中英

eclipse starting new instance of java to run the program

When I start the eclipse it starts an instance of Java but when I run the application it again starts the another instance of Java. Why it is not running the program on the previous generated instance.

After i started the eclipse

在此处输入图片说明

After I run any program in eclipse

在此处输入图片说明

If anybody know , please help...

Each running Java program requires its own instance of the Java Virtual Machine. Therefore if two instances of your program are running simultaneously, you are expected to see two Java processes.

If you "closed" your first program before running the second time, and the first Java process is still running, that just means that your program did not in fact end. This is most likely due to a bug in your code, for example you haven't ensured that closing your main GUI window ends the Java process.

In more general terms, you have caused some long-running threads to start and left them running (Swing's Event Dispatch Thread is one such example).

If you're using swing components such as JFrame for your main window, you must enable the functionality that lets the [X] close button exit the application. This is done through:

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM