So I have a java program of a game. I want to have a different program and when you click on a button there that java program closes and starts the program with the game. But I have no idea how I can do that, so can anyone help me?
Asked
Active
Viewed 130 times
0
-
did you google before ask? – shreyansh jogi Nov 27 '13 at 08:39
-
1Are you sure you want to start a new program or do you maybe just want to open another frame showing your program? – Matthias Nov 27 '13 at 08:40
-
Well I don't know whats easier, but I don't have a lot of Java knowledge. – user2971821 Nov 27 '13 at 08:41
-
It is way easier staying in your own program and just show another JFrame (assuming you coded that in swing) from your main method which then will open your game JFrame once the user click's that button. – Matthias Nov 27 '13 at 08:45
2 Answers
1
Using ProcessBuilder.The following is a reference,maybe not work.
ProcessBuilder pb=new ProcessBuilder("java","-jar","Test3.jar");
pb.directory(new File("F:\\dist"));
Map<String,String> map=pb.environment();
Process p=pb.start();

Su Xiang
- 11
- 2
0
- Create a runnable jar.
- call the runnable jar on button click.
- Exit from the current program.

Nishant Lakhara
- 2,295
- 4
- 23
- 46