Java 无法通过 Eclipse 创建可运行的 jar 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18218704/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't create a runnable jar file via Eclipse
提问by Yonatan Nir
I made a Java project with Eclipse. The project has a public static void main(String[] args)
method in it.
When I try to export it to a runnable jar, the launch configuration does not include the project I created so I can't create the jar for the project. Any ideas why?
我用 Eclipse 做了一个 Java 项目。该项目中有一个public static void main(String[] args)
方法。当我尝试将其导出到可运行的 jar 时,启动配置不包括我创建的项目,因此我无法为该项目创建 jar。任何想法为什么?
采纳答案by Jason C
Try creating a new launch configuration from scratch:
尝试从头开始创建一个新的启动配置:
Run
->Run Configurations...
- Right click "Java Application" in the list on the left and select
New
- On the right enter a descriptive name.
- In the Main tab browse for your project and search for and select the appropriate main class.
- Close the dialog.
Run
->Run Configurations...
- 右键单击左侧列表中的“Java 应用程序”并选择
New
- 在右侧输入描述性名称。
- 在 Main 选项卡中,浏览您的项目并搜索并选择适当的主类。
- 关闭对话框。
Now try exporting your runnable JAR again using that run configuration.
现在尝试使用该运行配置再次导出您的可运行 JAR。
回答by Xabster
Either run the project once to automatically create a run configuration or go into the project options and create one manually.
要么运行项目一次以自动创建运行配置,要么进入项目选项并手动创建一个。
回答by c0der
One more answer, in hope it will help some one:
I had a situation where the configuration did appear in the Run -> Run Configurations
list,
but did not appearon the list of the Ruannable JAR export wizard.
It was cured only after I closed and re-launched Eclipse.
还有一个答案,希望对大家有所帮助:
我遇到过这样一种情况,配置确实出现在Run -> Run Configurations
列表中,
但没有出现在 Ruannable JAR 导出向导的列表中。
只有在我关闭并重新启动 Eclipse 后它才被治愈。