生成的JAR文件未执行 [英] Generated JAR file is not executing
问题描述
我有一个java项目,它从excel表读取数据(由用户指定),执行一些过滤并创建一些文本文件,然后将修改后的数据写入文本文件。
I have a java project which reads data from an the excel sheet (specified by the user), performs some filtering and creates a few text files and then writes the modified data to the text files.
该项目工作正常,现在我想为它创建一个jar文件。我创建了jar文件,但它没有运行。就代码而言,它运行时没有任何错误。我使用Netbeans进行GUI。我还看到了相关的问题,说无法从正在运行的jar中创建文本文件。
The project is working fine and now I want to create a jar file for it. I created the jar file but it did not run. As far as the code is concerned it is running without any errors.I have used Netbeans for GUI. I also saw related questions which said it is not possible to create a text file from a running jar.
是否有解决方法?
推荐答案
您需要在jar文件的清单中指定主类。
You need to specify the main class in the manifest of the jar file.
如果您的应用程序捆绑在JAR文件中,则需要某种方法来指示JAR文件中的哪个类是应用程序的入口点。您使用清单中的Main-Class标头提供此信息,该标头具有以下一般形式:Main-Class:classname
If you have an application bundled in a JAR file, you need some way to indicate which class within the JAR file is your application's entry point. You provide this information with the Main-Class header in the manifest, which has the general form: Main-Class: classname
http://docs.oracle.com/javase/tutorial/deployment/jar/appman .html
这篇关于生成的JAR文件未执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!