eclipse在创建jar文件时找不到主方法

huangapple go评论94阅读模式
英文:

eclipse can't find main method when I make a jar

问题

  1. 所以我已经编写好了代码

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){

  1. }
  2. @Override
  3. public void start(Stage primaryStage) throws Exception {
  4. primaryStage.setTitle("title");
  5. Pane pain = (Pane) FXMLLoader.load(main.class.getResource("gui.fxml"));
  6. primaryStage.setScene(new Scene(pain));
  7. primaryStage.show();
  8. }

}

  1. 并且它通常可以正常运行。
  2. 然后我设置了配置
  3. 主类: application.main
  4. 项目JRE: jre1.8.0_251
  5. 这样也可以正常运行。
  6. 然后我导出/生成可运行的JAR文件
  7. 选择了该启动配置
  8. 导出至 C:\Users\clark\OneDrive\Documents\FRM.jar
  9. 提取所需的库
  10. 点击完成后会弹出以下内容
  11. JAR导出完成,但有问题。
  12. 无法从给定的启动配置中找到主要方法。
  13. MANIFEST.mf

Manifest-Version: 1.0
Main-Class: main
Created-By: 13.0.1 (Oracle Corporation)

英文:

so I have the code made

  1. package application;
  2. import javafx.application.Application;
  3. import javafx.fxml.FXMLLoader;
  4. import javafx.scene.Scene;
  5. import javafx.scene.layout.Pane;
  6. import javafx.stage.Stage;
  7. public class main extends Application{
  8. public static void Main (String[] args){
  9. }
  10. @Override
  11. public void start(Stage primaryStage) throws Exception {
  12. primaryStage.setTitle("title");
  13. Pane pain = (Pane) FXMLLoader.load(main.class.getResource("gui.fxml"));
  14. primaryStage.setScene(new Scene(pain));
  15. primaryStage.show();
  16. }
  17. }

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

  1. Manifest-Version: 1.0
  2. Main-Class: main
  3. Created-By: 13.0.1 (Oracle Corporation)

答案1

得分: 1

你的主方法命名不正确。请将

  1. public static void Main (String[] args)

修改为

  1. public static void main (String[] args)

请注意,m 需要小写。

英文:

Your main method is named wrong. Change

  1. public static void Main (String[] args)

to

  1. public static void main (String[] args)

Note that the m needs to be lower case

huangapple
  • 本文由 发表于 2020年9月2日 18:50:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/63703960.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定