Java 尝试导出可运行 Jar 时,“启动配置”显示为空白?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3224364/
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
"Launch Configuration" Shows up Blank When Trying to Export Runnable Jar?
提问by Justian Meyer
I've gotten this to work in the past, but now whenever I choose File > Export... > Runnable JAR File
and select the drop-down menu "Launch Configuration"
, all I get is a blank bar.
过去我已经让它工作了,但现在每当我选择File > Export... > Runnable JAR File
下拉菜单时"Launch Configuration"
,我得到的只是一个空白栏。
How can I get my main class to show up?
我怎样才能让我的主班出现?
采纳答案by Thorbj?rn Ravn Andersen
Launch configurations are presumably used because they describe the main class you want to run, and the libraries the main class needs. They are created automatically when you run your main class inside Eclipse.
可能会使用启动配置,因为它们描述了您要运行的主类以及主类需要的库。当您在 Eclipse 中运行主类时,它们会自动创建。
In the Package Explorer panel, right-click on the class you want to have main(...) executed in and choose Run as -> Java Application
to run your program.
在 Package Explorer 面板中,右键单击要在其中执行 main(...) 的类,然后选择Run as -> Java Application
运行您的程序。
This process creates a launch configuration you can use (and save too, if you make it shared)
此过程会创建一个您可以使用的启动配置(如果您将其共享,也可以保存)
回答by Carl Smotricz
This "launch configuration" thingie is all fine and good, but you probably just want to specify a main class. One of the pages of the "export" dialog will let you browse for and specify that main class, without the need to go looking for an appropriate configuration. That's how I do it.
这个“启动配置”东西很好,但你可能只想指定一个主类。“导出”对话框的其中一页将让您浏览并指定该主类,而无需寻找合适的配置。我就是这样做的。
EDIT
编辑
What I do is
我做的是
File | Export | Java | Jar File
档案 | 出口 | 爪哇| Jar 文件
Then I select the stuff I want exported.
然后我选择我想要导出的东西。
Next | Next and I get a chance to specify my main file.
下一页 | 接下来,我有机会指定我的主文件。
回答by RickyNevada
I came across this same issue today as I have many times in the past, and although I've usually corrected it as Thorbjorn has posted, for some reason it was not working for me today.
我今天遇到了与过去多次相同的问题,虽然我通常会像 Thorbjorn 发布的那样纠正它,但由于某种原因,它今天对我不起作用。
Typically I would just browse to the project, search for the main class, and hit apply then run, but it wasn't working. Still wouldn't show main class while trying to export runnable jar.
通常我会浏览到项目,搜索主类,然后点击应用然后运行,但它不起作用。尝试导出可运行的 jar 时仍然不会显示主类。
I actually had to go run configurations, and right click on the window to the left under Java Application and click 'new'. It then created a new configuration item where I could browse to the project, and add the main class. Then it would show up while trying to export runnable jar.
我实际上必须运行配置,然后右键单击 Java 应用程序下左侧的窗口,然后单击“新建”。然后它创建了一个新的配置项,我可以在其中浏览到项目,并添加主类。然后它会在尝试导出可运行的 jar 时出现。