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

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

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

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:

确定