简体   繁体   中英

Running a jar file from terminal in ubuntu

I have a jar file , which when i execute by

 java -jar firstjar.jar

I get the following errors

Error: Invalid or corrupt jarfile firstjar.jar

Here is my manifest file

 Manifest-Version: 1.0
 Created-By: 1.7.0_79 (Oracle Corporation)
 Class-Path:mysql-connector-java-5.1.28.jar
 Main-Class:JavaApplication1

Contents of jar file

0 Wed May 13 14:09:06 IST 2015 META-INF/
140 Thu May 14 00:26:26 IST 2015 META-INF/MANIFEST.MF
2917 Wed May 13 13:16:02 IST 2015 JavaApplication1.class

Thanks in advance!

Perhaps your jarfile is corrupted in some way, possibly due to how it was downloaded or installed.

this issue is caused by manifest file because you haven't added space after every colon in here, it should be:

Manifest-Version: 1.0 
Created-By: 1.7.0_79 (Oracle Corporation) 
Class-Path: mysql-connector-java-5.1.28.jar 
Main-Class: JavaApplication1 

after Main-Class there must be a Blank line see here https://docs.oracle.com/javase/tutorial/deployment/jar/modman.html .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM