Invalid or corrupt jarfile export.jar. This issue occurs when the Java version installed in your machine is not version 8.
A JAR file is based on a Java archive file format that may include a Java program inside it. Although you can use a zip file extracting software like the 7zip to extract the . JAR files, it won't allow you to run a compete Java app based on . JAR.
What is JAR? JAR stands for Java ARchive. It's a file format based on the popular ZIP file format and is used for aggregating many files into one. Although JAR can be used as a general archiving tool, the primary motivation for its development was so that Java applets and their requisite components (.
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.
[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 "%~dp0\myjar.jar"
Credit goes to this answer for setting me on the right path....
I had this issue under CygWin in Windows. I have read elsewhere that Java does not understand the CygWin paths (/cygdrive/c/some/dir
instead of C:\some\dir
) - so I used a relative path instead: ../../some/dir/sbt-launch.jar
.
I had the same issue when trying to launch the jar file. The path contained a space, so I had to place quotes around. Instead of:
java -jar C:\Path to File\myJar.jar
i had to write
java -jar "C:\Path to File\myJar.jar"
Just came across the same problem trying to make a bad USB...
I tried to run this command in admin cmd
java -jar c:\fw\ducky\duckencode.jar -I c:\fw\ducky\HelloWorld.txt -o c:\fw\ducky\inject.bin
But got this error:
Error: unable to access jarfile c:\fw\ducky\duckencode.jar
Solution
1st step
Right click the jarfile in question. Click properties. Click the unblock tab in bottom right corner. The file was blocked, because it was downloaded and not created on my PC.
2nd step
In the cmd I changed the directory to where the jar file is located.
cd C:\fw\ducky\
Then I typed dir
and saw the file was named duckencode.jar.jar
So in cmd I changed the original command to reference the file with .jar.jar
java -jar c:\fw\ducky\duckencode.jar.jar -I c:\fw\ducky\HelloWorld.txt -o c:\fw\ducky\inject.bin
That command executed without error messages and the inject.bin I was trying to create was now located in the directory.
Hope this helps.
I had a similar problem and I even tried running my CMD with administrator rights, but it did not solve the problem.
The basic thing is to make sure to change the Directory in cmd to the current directory where your jar file is.
Do the following steps:
Copy jar file to Desktop.
Run CMD
Type command cd desktop
Then type java -jar filename.jar
This should work.
Edit: From JDK-11 onwards ( JEP 330: Launch Single-File Source-Code Programs )
Since Java 11, java command line tool has been able to run a single-file source-code directly. e.g.
java filename.java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With