What causes "Unable to access jarfile" error?

Joseph Smith picture Joseph Smith · Aug 14, 2012 · Viewed 674.7k times · Source

I want to execute my program without using an IDE. I've created a jar file and an exectuable jar file. When I double click the exe jar file, nothing happens, and when I try to use the command in cmd it gives me this:

Error: Unable to access jarfile <path>

I use the command: java -jar Calculator.jar

How I created the jar:

  1. Right click on project folder (Calculator)
  2. Select
  3. Click on Java Folder and select "Exectuable Jar File", then select next
  4. Launch Configuration: Main - Calculator
  5. Create Export Destination
  6. Hit "Finish" and profit! Well, not really.

Answer

Vinay Kadalagi picture Vinay Kadalagi · Sep 16, 2014

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.