Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error unable to access jarfile C:\Jar

My jar file P2.jar (which has a main method and manifest file) is located in C:\Jar Folder. I tried to run it from cmd like this:

C:SomeRandomFolder> java -jar C:\Jar Folder\P2.jar

I get the error:

unable to access jarfile C:\Jar

It works when I run it from the folder that the jar is in like this:

C:\Jar Folder> java -jar P2.jar

Why can't I use the 1st command? Why do I have to go to the directory of my jar file?

like image 562
Apple Grinder Avatar asked Nov 29 '12 01:11

Apple Grinder


1 Answers

That's because of the space you have in the path name. On Windows, use quotes:

java -jar "C:\Jar Folder\P2.jar"

like image 170
Isaac Avatar answered Oct 24 '22 15:10

Isaac