从给定的启动配置中找不到主要方法
我有一个简单的Java项目,当我在Eclipse环境中执行它时可以使用。但是,当我尝试将其导出到可运行的jar 时,我会收到以下错误:
JAR export finished with warnings. See details for additional information.
Exported with compile warnings: JavaSwing/src.main.java/com/cansoft/GUIProgram.java
Exported with compile warnings: JavaSwing/src.main.java/com/util/Util.java
Jar export finished with problems. See details for additional information.
Could not find main method from given launch configuration.
我读了其他建议创建subtest.mf文件的帖子,以指定我所做的主流。它放置在myprojectFolder/meta-inf/subest.mf上,其中包含以下信息:
Manifest-Version: 1.0
Class-Path: resources
main-class: com.cansoft.GUIProgram
我的主要类别如下:
public class GUIProgram {
private JFrame folderCreationSubappFrame;
private Color color;
private String home;
private final static Logger LOG_MONITOR = Logger.getLogger("com.cansoft");
public static void main(String[] args) {
try {
new GUIProgram();
} catch (Exception e) {
LOG_MONITOR.log(Level.INFO,e.getMessage());
}
}
public GUIProgram() throws InterruptedException, SecurityException, IOException {
home = System.getProperty("user.home") + File.separator + "Documents";
startLogSystem();
if(isFirstRun()) {
showWelcomeFrame();
} else {
initialize();
}
} .... More and more code
有人知道我缺少什么吗?任何帮助都非常感谢。
谢谢。
I've a simple Java project that works when I execute it at Eclipse environment. But when I try to export it to a Runnable Jar, I get the following error:
JAR export finished with warnings. See details for additional information.
Exported with compile warnings: JavaSwing/src.main.java/com/cansoft/GUIProgram.java
Exported with compile warnings: JavaSwing/src.main.java/com/util/Util.java
Jar export finished with problems. See details for additional information.
Could not find main method from given launch configuration.
I read other posts which suggest to create a MANIFEST.MF file specifying the main-class which I did. It is placed at MyProjectFolder/META-INF/MANIFEST.MF and it contains the following information:
Manifest-Version: 1.0
Class-Path: resources
main-class: com.cansoft.GUIProgram
My main class is as follows:
public class GUIProgram {
private JFrame folderCreationSubappFrame;
private Color color;
private String home;
private final static Logger LOG_MONITOR = Logger.getLogger("com.cansoft");
public static void main(String[] args) {
try {
new GUIProgram();
} catch (Exception e) {
LOG_MONITOR.log(Level.INFO,e.getMessage());
}
}
public GUIProgram() throws InterruptedException, SecurityException, IOException {
home = System.getProperty("user.home") + File.separator + "Documents";
startLogSystem();
if(isFirstRun()) {
showWelcomeFrame();
} else {
initialize();
}
} .... More and more code
Does anybody know what am I missing? Any help much appreciated.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建清单文件还不够,您需要在Eclipse Jar导出对话框中明确选择它。
回答以评论
如果使用“可运行的JAR”,请确保选择正确的启动配置,并且在选择“运行为“ - &gt”时,启动配置成功运行; “运行配置” - > “ Java应用程序” - >您的配置 - > “跑步”
It is not enough to create the manifest file, you need to explicitly choose it in the Eclipse jar export dialog.
Answer to Comment
If you use "runnable jar", make sure that you chose the correct launch configuration and that the launch configuration successfully runs when chosing "Run As" -> "Run Configurations" -> "Java Application" -> Your Configuration -> "Run"
我终于发现了问题所在,这很简单。我已经在
src.main.java
软件包中创建了我的概述,但是创建了该软件包(我的糟糕)为 Resources 而不是文件夹,因此Eclipse足够聪明,可以运行但是,当试图生成期望正确的Java项目结构的JAR时,它是失败的,因为确实没有guiprogram Java类,src
path(SRC不是文件夹类型,而是资源)。希望我能成功解释。
I finally find out where the problem was, it was quite simple btw. I had created my GUIProgram within a
src.main.java
package, but that package was created (my bad) as resources instead of folders, so Eclipse was smart enought to run it but when trying to generate the JAR which expected a correct java project structure, it was failing because truly there were not GUIProgram java class atsrc
path (src was not folder type but resources).Hope I succeed explaining.