java – What causes Unable to access jarfile error?

java – What causes Unable to access jarfile error?

I had encountered this issue when I had run my Jar file as

java -jar TestJar

instead of

java -jar TestJar.jar

Missing the extension .jar also causes this issue.

Fixed

I just placed it in a different folder and it worked.

java – What causes Unable to access jarfile error?

[Possibly Windows only]

Beware of spaces in the path, even when your jar is in the current working directory. For example, for me this was failing:

java -jar myjar.jar

I was able to fix this by givng the full, quoted path to the jar:

java -jar %~dp0myjar.jar 

Credit goes to this answer for setting me on the right path….

Leave a Reply

Your email address will not be published.