1

I am simply trying to implement a button which will re run a main file in my program. So, essentially when the button is clicked, the application will restart, and it will be like the user is playing the game again from the start. Is this possible? and if so how would I go about coding this button? I am using netbeans IDE 8.0 Thank you all very much for taking the time to try and help me out :) I appreciate it. Kind regards.

Extra Edit 1: Is there anything that will just reopen the main class? I read somewhere that Application.Restart() will work in a C# application. Is there anything like this for NetBeans? Cheers in advance

2 Answers2

1

for restarting application you can use below code

Runtime.getRuntime().exec("java -jar myApp.jar");
System.exit(0);

in netbeans platform application you can use this command

LifecycleManager.getDefault().markForRestart();
LifecycleManager.getDefault().exit();
Mehdi Varse
  • 271
  • 1
  • 15
0

Surely reading this will help: http://docs.oracle.com/javase/tutorial/essential/concurrency/runthread.html

You should create a thread where the game is run. Each time you pressed or reboot or wake up the thread.

I hope it's some help.

York Xtrem
  • 58
  • 1
  • 10