0

I am trying to run a jar file from my java program:

ProcessBuilder pb = new ProcessBuilder("java", "-jar", "D:\\my.jar"); 
Process p = pb.start();

But I am getting this exception:

Unable to access jarfile D:\my.jar

I am trying this on Windows OS. Am I doing something wrong?

M-Wajeeh
  • 16,948
  • 10
  • 63
  • 98

2 Answers2

1

My bad, I don't know how I missed it but I was not giving complete name of my jar file:

ProcessBuilder pb = new ProcessBuilder("java", "-jar", "D:\\my.1.6.2.jar"); //<----
Process p = pb.start();

Anyways its working now. Thanks to all those who tried to help.

M-Wajeeh
  • 16,948
  • 10
  • 63
  • 98
0

Um...use Apache Commons Exec isntead. It will relieve you from too much unnecessary trouble.

Muhammad Gelbana
  • 3,800
  • 3
  • 36
  • 77