我已经创建了一个Java Swing应用程序,现在我想将其导出为可执行jar
文件。我在eclipse中创建了应用程序,它具有以下结构:
其中文件夹mysqlconnector
也包含jar
文件。我在制作名为manifest
的{{1}}文件时做了三件不同的努力:
1。
manifest.mf
2。
Main-Class: bin.main.MainClass
3。
Main-Class: src.main.MainClass
我将 Main-Class: MainClass
放在文件夹manifest.mf
中,并在终端中提供了以下命令:
seo
创建jar -cvfm seo.jar manifest.mf *
后,命令:
jar
给我以下输出:
jar -tvf seo.jar
但是当我从终端0 Wed Mar 15 09:13:26 EET 2017 META-INF/
101 Wed Mar 15 09:13:26 EET 2017 META-INF/MANIFEST.MF
0 Fri Dec 09 14:00:06 EET 2016 arial-unicode-ms/
23275812 Fri Dec 09 14:00:06 EET 2016 arial-unicode-ms/ARIALUNI.TTF
2426 Fri Dec 09 14:00:06 EET 2016 arial-unicode-ms/arial-unicode-ms.png
98 Fri Dec 09 14:00:06 EET 2016 arial-unicode-ms/myfontsfree.txt
23275812 Fri Dec 09 13:59:58 EET 2016 ARIALUNI.TTF
0 Mon Mar 13 11:35:16 EET 2017 bin/
0 Mon Mar 13 09:03:32 EET 2017 bin/gui/
5702 Mon Mar 13 09:03:32 EET 2017 bin/gui/GuiFrame.class
73666 Mon Mar 13 09:03:24 EET 2017 bin/gui/img.png
0 Wed Mar 15 09:10:16 EET 2017 bin/main/
1961 Mon Mar 13 09:03:32 EET 2017 bin/main/ReadProperties.class
1007 Mon Mar 13 11:30:24 EET 2017 bin/main/MainClass.class
0 Mon Mar 13 11:29:12 EET 2017 bin/main/resources/
157 Mon Mar 13 11:29:12 EET 2017 bin/main/resources/connectionprops.properties
0 Mon Mar 13 09:03:32 EET 2017 bin/listeners/
5395 Mon Mar 13 09:03:32 EET 2017 bin/listeners/RegisterIdListener.class
5065 Mon Mar 13 09:03:32 EET 2017 bin/listeners/PayIdListener.class
5081 Mon Mar 13 09:03:32 EET 2017 bin/listeners/StarToBirdListener.class
5095 Mon Mar 13 09:03:32 EET 2017 bin/listeners/DeleteStarListener.class
648 Mon Mar 13 09:03:32 EET 2017 bin/listeners/GoBackListener.class
2707 Mon Mar 13 09:03:32 EET 2017 bin/listeners/DeleteListener.class
73666 Mon Mar 13 09:03:24 EET 2017 bin/listeners/img.png
2612 Mon Mar 13 09:03:32 EET 2017 bin/listeners/NewYearListener.class
6023 Mon Mar 13 09:03:32 EET 2017 bin/listeners/PassListener.class
6710 Mon Mar 13 09:03:32 EET 2017 bin/listeners/AllListener.class
3523 Mon Mar 13 09:03:32 EET 2017 bin/listeners/PdfListener.class
7011 Mon Mar 13 09:03:32 EET 2017 bin/listeners/NewStarListener.class
6620 Mon Mar 13 09:03:32 EET 2017 bin/listeners/PaidIdListener.class
2644 Mon Mar 13 09:03:32 EET 2017 bin/listeners/PayListener.class
6737 Mon Mar 13 09:03:32 EET 2017 bin/listeners/GotIdListener.class
6671 Mon Mar 13 09:03:32 EET 2017 bin/listeners/ToBirdsListener.class
5474 Mon Mar 13 09:03:32 EET 2017 bin/listeners/ReportsListener.class
5385 Mon Mar 13 09:03:32 EET 2017 bin/listeners/NewListener.class
2892 Mon Mar 13 09:03:32 EET 2017 bin/listeners/RegisterListener.class
0 Mon Mar 13 11:35:16 EET 2017 bin/META-INF/
53 Mon Mar 13 11:35:16 EET 2017 bin/META-INF/MANIFEST.MF
73666 Mon Mar 13 09:03:24 EET 2017 bin/img.png
0 Mon Mar 13 11:35:18 EET 2017 classes/
0 Mon Mar 13 11:35:18 EET 2017 classes/artifacts/
0 Mon Mar 13 11:35:18 EET 2017 classes/artifacts/seo_jar/
3406481 Mon Mar 13 11:35:18 EET 2017 classes/artifacts/seo_jar/seo.jar
157 Sun Jan 22 18:26:06 EET 2017 connectionprops.properties
2148384 Mon Nov 14 17:22:10 EET 2016 itextpdf-5.5.4.jar
31 Mon Mar 13 09:27:02 EET 2017 manifest.mf
0 Thu Dec 08 14:32:48 EET 2016 mysqlconnector/
960374 Fri Oct 17 08:05:36 EEST 2014 mysqlconnector/mysql-connector-java-5.1.34-bin.jar
1358 Fri Mar 10 09:57:22 EET 2017 seo.iml
0 Wed Mar 15 09:11:32 EET 2017 src/
0 Wed Feb 01 15:01:04 EET 2017 src/gui/
73666 Fri Dec 09 13:56:32 EET 2016 src/gui/img.png
5617 Wed Feb 01 12:15:26 EET 2017 src/gui/GuiFrame.java
0 Wed Mar 15 09:08:44 EET 2017 src/main/
601 Fri Mar 03 19:11:24 EET 2017 src/main/MainClass.java~
1315 Sun Jan 22 18:30:54 EET 2017 src/main/ReadProperties.java
1060 Mon Mar 13 11:30:24 EET 2017 src/main/MainClass.java
0 Mon Mar 13 11:27:02 EET 2017 src/main/resources/
157 Sun Jan 22 18:26:06 EET 2017 src/main/resources/connectionprops.properties
48 Wed Mar 15 09:08:32 EET 2017 src/main/MANIFEST.MF
0 Fri Mar 10 10:55:40 EET 2017 src/listeners/
4761 Wed Feb 01 15:33:12 EET 2017 src/listeners/DeleteStarListener.java
5330 Fri Mar 10 10:55:38 EET 2017 src/listeners/PaidIdListener.java
5268 Fri Mar 10 10:55:40 EET 2017 src/listeners/GotIdListener.java
5233 Fri Mar 10 10:55:40 EET 2017 src/listeners/ToBirdsListener.java
5217 Wed Feb 01 15:33:52 EET 2017 src/listeners/RegisterIdListener.java
405 Wed Feb 01 15:32:56 EET 2017 src/listeners/GoBackListener.java
2361 Wed Feb 01 12:13:34 EET 2017 src/listeners/PdfListener.java
5761 Fri Mar 10 10:55:40 EET 2017 src/listeners/AllListener.java
4700 Wed Feb 01 15:33:30 EET 2017 src/listeners/PayIdListener.java
5165 Fri Mar 10 10:15:20 EET 2017 src/listeners/NewListener.java
4717 Wed Feb 01 15:33:18 EET 2017 src/listeners/StarToBirdListener.java
5222 Fri Mar 10 10:12:06 EET 2017 src/listeners/ReportsListener.java
5922 Fri Mar 10 10:17:32 EET 2017 src/listeners/PassListener.java
73666 Fri Dec 09 13:56:32 EET 2016 src/listeners/img.png
2333 Wed Feb 01 12:13:34 EET 2017 src/listeners/NewYearListener.java
6827 Wed Feb 01 15:33:36 EET 2017 src/listeners/NewStarListener.java
2008 Fri Mar 10 10:14:06 EET 2017 src/listeners/PayListener.java
2162 Fri Mar 10 10:15:20 EET 2017 src/listeners/RegisterListener.java
1982 Fri Mar 10 10:15:20 EET 2017 src/listeners/DeleteListener.java
73666 Fri Dec 09 13:56:32 EET 2016 src/img.png
执行时,我收到错误:
错误:无法找到或加载主类bin.main.MainClass
或
错误:无法找到或加载主类src.main.MainClass
或
错误:无法找到或加载主类MainClass
根据我在清单文件中指定的主类。
我做错了什么?我应该改变项目结构中的某些内容吗?如何创建可执行文件java -jar seo.jar
并成功执行它?