英文:
eclipse can't find main method when I make a jar
问题
所以我已经编写好了代码
package application;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class main extends Application{
public static void Main (String[] args){
}
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("title");
Pane pain = (Pane) FXMLLoader.load(main.class.getResource("gui.fxml"));
primaryStage.setScene(new Scene(pain));
primaryStage.show();
}
}
并且它通常可以正常运行。
然后我设置了配置
主类: application.main
项目JRE: jre1.8.0_251
这样也可以正常运行。
然后我导出/生成可运行的JAR文件
选择了该启动配置
导出至 C:\Users\clark\OneDrive\Documents\FRM.jar
提取所需的库
点击完成后会弹出以下内容
JAR导出完成,但有问题。
无法从给定的启动配置中找到主要方法。
MANIFEST.mf
Manifest-Version: 1.0
Main-Class: main
Created-By: 13.0.1 (Oracle Corporation)
英文:
so I have the code made
package application;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class main extends Application{
public static void Main (String[] args){
}
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("title");
Pane pain = (Pane) FXMLLoader.load(main.class.getResource("gui.fxml"));
primaryStage.setScene(new Scene(pain));
primaryStage.show();
}
}
and it runs fine normally.
then I set up the configurations
Main class: application.main
project JRE jre1.8.0_251
and that runs just fine.
then I export/ Runnable JAR file
select that launch configuration
export to C:\Users\clark\OneDrive\Documents\FRM.jar
Extract required libraries
hit finish and the following pops up
Jar export finished with problems.
Could not find main method from given launch configuration.
MANIFEST.mf
Manifest-Version: 1.0
Main-Class: main
Created-By: 13.0.1 (Oracle Corporation)
答案1
得分: 1
你的主方法命名不正确。请将
public static void Main (String[] args)
修改为
public static void main (String[] args)
请注意,m 需要小写。
英文:
Your main method is named wrong. Change
public static void Main (String[] args)
to
public static void main (String[] args)
Note that the m needs to be lower case
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论