0

I am making a Launcher for a game in java but I would like to make the launcher open the game which is in another file . how can I do this ?

I've tryied this:

Process p = Runtime.getRuntime().exec("javaw.exe C:\\SnowRPG\\Game.jar");

but it isn't openning the java program located in C:\SnowRPG\Game.jar.

System.out.println("launching with profil [" + username_field.getText() + "," + password_field.getText() + "]");
try {
    Process p = Runtime.getRuntime().exec("javaw.exe d:\\C:\\SnowRPG\\Game.jar");
} catch (IOException e1) {
    e1.printStackTrace();
}

it is supposed to open the game located in C:/SnowRPG/Game.jar when I press the button play

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
  • have you tried to type that command in a command line to check it? (and looks like there is a typo `C:` or `d:`) Hint, not sure if that helps: you can, if the jar is in the classpath used for the actual program, just call the static `main` method of the main class (providing an {empty} string array with arguments) – user85421 Oct 31 '19 at 20:06
  • Just to confirm : you have checked and are certainly NOT getting an exception - correct ? – racraman Oct 31 '19 at 20:46

1 Answers1

0

Try executing the command on a command line. If it doesn't work there, it's not going to work when you try to run the same command from java.

LowKeyEnergy
  • 652
  • 4
  • 11