0

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?

4
  • did you google before ask? Commented Nov 27, 2013 at 8:39
  • 1
    Are you sure you want to start a new program or do you maybe just want to open another frame showing your program? Commented Nov 27, 2013 at 8:40
  • Well I don't know whats easier, but I don't have a lot of Java knowledge. Commented Nov 27, 2013 at 8: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. Commented Nov 27, 2013 at 8:45

2 Answers 2

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();
Sign up to request clarification or add additional context in comments.

Comments

0
  1. Create a runnable jar.
  2. call the runnable jar on button click.
  3. Exit from the current program.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.