Error unable to access jarfile C:\Jar

command-line, java

Solution

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

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

Problem

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?

Original source