简体   繁体   English

我的.jar文件在java中不起作用

[英]My .jar file is not working in java

I have created an application and it is working correctly when I am executing it through NETBEANS. 我创建了一个应用程序,当我通过NETBEANS执行它时它正常工作。

After that I had clicked on "Clean and Build" to build a SiteScrapper.jar file. 之后,我点击了“清理并构建”来构建SiteScrapper.jar文件。 Now when I am executing it through command prompt by invoking the following dos command: 现在,当我通过命令提示符执行它时,通过调用以下dos命令:

java -jar "SiteScrapper.jar"

I am getting the following exception 我收到以下异常

sitescrapper.Main class not found

My Main class is located in the following package 我的主类位于以下包中

com.innoConsulting.sitescrapper

您需要检查清单文件中Main-Class的值。

您的JAR需要一个META-INF / manifest.mf文件来说明主类的位置。

You need to include a manifest file. 您需要包含清单文件。 See here for a quick explanation: http://www.skylit.com/javamethods/faqs/createjar.html 请参阅此处以获得快速解释: http//www.skylit.com/javamethods/faqs/createjar.html

In Netbeans either run the project (and it will ask you for the Main-Class) or go into the Project | 在Netbeans中运行项目(它会询问您的Main-Class)或进入Project | Properties | 属性| Run and select the Main-Class. 运行并选择Main-Class。

Then do another clean and build and it will generate the JAR file with the appropriate manifest file (with the Main-Class: set). 然后执行另一个清理和构建,它将生成带有相应清单文件的JAR文件(使用Main-Class:set)。

Make sure that the jar file is 'executable'. 确保jar文件是“可执行的”。 The Manifest needs to have the Main-Class attribute. Manifest需要具有Main-Class属性。

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

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