简体   繁体   English

从Ubuntu中的终端运行jar文件

[英]Running a jar file from terminal in ubuntu

I have a jar file , which when i execute by 我有一个jar文件,当我执行时

 java -jar firstjar.jar

I get the following errors 我收到以下错误

Error: Invalid or corrupt jarfile firstjar.jar 错误: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 jar文件的内容

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. 可能您的jarfile在某种程度上已损坏,可能是由于其下载或安装方式所致。

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 . 在Main-Class之后,必须有一个空白行,请参见https://docs.oracle.com/javase/tutorial/deployment/jar/modman.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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