[英]eclipse cannot find main method from given launch configuration
I went to eclipse>export>java>runnable jar file 我去了eclipse> export> java> runnable jar文件
I changed launch configuration to my project name; 我将启动配置更改为项目名称。 destination: desktop.
目的地:台式机。
I tried all three library handling options: 我尝试了所有三个库处理选项:
I did not check anything to do with "ANT scripts". 我没有检查任何与“ ANT脚本”有关的内容。
When I pressed "finish" in the export window, eclipse gave me a error: "Could not find main method from given launch configuration". 当我在导出窗口中按“完成”时,eclipse给了我一个错误:“无法从给定的启动配置中找到主要方法”。 After pressing the "finish" button in the eclipse export window, the next button was grayed out.
在日食导出窗口中按下“完成”按钮后,下一个按钮显示为灰色。 It created a JAR file at the destination.
它在目标位置创建了一个JAR文件。 When I tried to open it Mac's Jar Launcher (default)(13.5.0), it gave me the message:
当我尝试打开Mac的Jar启动器(默认)(13.5.0)时,它给了我消息:
The Java JAR file "filename.jar" could not be launched.
无法启动Java JAR文件“ filename.jar”。
Check the Console for possible error messages.
检查控制台以获取可能的错误消息。
I googled this and some people said to check the manifest.mf file. 我用谷歌搜索,有人说要检查manifest.mf文件。 I extracted it, then: "META-INF>manifest.mf".
我提取了它,然后:“ META-INF> manifest.mf”。 I opened manifest.mf with textedit.
我用textedit打开manifest.mf。 Inside manifest.mf were the lines:
在manifest.mf内部是以下几行:
Manifest-Version: 1.0
清单版本:1.0
Rsrc-Class-Path: ./ acm.jar
Rsrc-Class-Path:./ acm.jar
Class-Path: .
类路径:。
I am running Mac OSx 10.6.8 snow leopard. 我正在运行Mac OSx 10.6.8雪豹。 I have the latest java available for snow leopard (I think my java is the one just BEFORE java 7).
我有可用于雪豹的最新Java(我认为我的Java是Java 7之前的Java)。
Also, I'm trying to export a project with: 另外,我正在尝试导出具有以下内容的项目:
My .java file contains a public void run() {}
and JFrames/JPanels. 我的.java文件包含一个
public void run() {}
和JFrames / JPanels。 My .java file extends ConsoleProgram. 我的.java文件扩展了ConsoleProgram。
If there's no public static void main(String[] args)
method, the virtual machine (Java) will not know where to start your program. 如果没有
public static void main(String[] args)
方法,则虚拟机(Java)将不知道从何处启动程序。 It sounds like your run()
method is what you want to start your program. 听起来您的
run()
方法就是您要启动程序的方法。 If so, then add (to your main class (.java)) a method: public static void main(String[] args)
. 如果是这样,则(在您的主类(.java)中)添加一个方法:
public static void main(String[] args)
。 Re-export your .jar, making sure the launch configuration is set to your Project name, and your main class. 重新导出您的.jar,确保将启动配置设置为您的Project名称和您的主类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.