简体   繁体   English

eclipse无法从给定的启动配置中找到主要方法

[英]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: 我尝试了所有三个库处理选项:

  1. extract required folders into generated JAR 将所需的文件夹提取到生成的JAR中
  2. Package required libraries into generated JAR 将所需的库打包到生成的JAR中
  3. copy required files into a sub-folder next to the generated JAR. 将所需文件复制到生成的JAR旁边的子文件夹中。

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: 另外,我正在尝试导出具有以下内容的项目:

  1. a .java file that contains all my code 包含我所有代码的.java文件
  2. acm.jar acm.jar
  3. java.policy.applet java.policy.applet
  4. Scores.txt Scores.txt

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.

相关问题 从Eclipse导出jar时“无法从给定的启动配置中找到main方法”错误 - “Could not find main method from given launch configuration” error when exporting jar from Eclipse Java 9 Eclipse 4.7便携式导出错误“找不到资源”,“无法从给定的启动配置中找到主要方法”。 - Java 9 Eclipse 4.7 Portable export error “resource not found”, “Could not find main method from given launch configuration.” 使用 Java+Scala+Slick2D 时“无法从给定的启动配置中找到主要方法” - "Could not find main method from given launch configuration" when using Java+Scala+Slick2D Scala和Eclipse:导出为Jar文件,但找不到主要方法 - Scala and Eclipse: Export as Jar File, but cannot find main method Eclipse在JFace中找不到主类? - Eclipse cannot find the main class in JFace? Java:Eclipse:找不到主类 - Java: Eclipse: Cannot Find Main Class Eclipse 找不到 Maven 项目的主类 - Eclipse cannot find main class of maven project 从类型为“ Class”的对象启动main方法 <?> ” - Launch main method from object with type “Class<?>” eclipse无法运行主程序“找不到或加载主类错误” - eclipse cannot run main “error could not find or load main class” Eclipse启动现有的启动配置 - Eclipse launch existing launch-configuration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM