[英]create a jar file in the current directory
I am looking to create a jar file in the current directory. 我正在寻找在当前目录中创建一个jar文件。
I did this in command line: 我在命令行中这样做:
jar cfe MyApp.jar MyApp MyApp.class
Alternatively, i put the following into Mnf.txt: 或者,我将以下内容放入Mnf.txt:
Main-Class: MyApp.class
and ran 跑了
jar cfm MyApp.jar Mnf.txt MyApp.class
When i try to run it with 当我尝试使用
java jar MyApp.jar
I get the following error in both cases: 在这两种情况下,我都会收到以下错误消息:
Error: could not find or load main class.
Mnf.txt & MyApp.class is in the current directory. Mnf.txt和MyApp.class在当前目录中。
There`s no package definition in MyApp. MyApp中没有包定义。 Everything is in the current directory.
一切都在当前目录中。
I`ve seen How can I convert my Java program to an .exe file? 我已经看到了如何将Java程序转换为.exe文件? among others.
其中。
No idea what i`m missing here. 不知道我在这里想念什么。
//=================== // ===================
ADD: 加:
Changing the content of Mnf.txt to: 将Mnf.txt的内容更改为:
Main-Class: MyApp
didn't change anything. 没有改变任何东西。 i'm getting the same error.
我遇到同样的错误。
Do not add ".class" to the name of the class in the manifest. 不要在清单中的类名称上添加“ .class”。
Java differentiates rather strongly between names of files on disk and class names. Java在磁盘文件名和类名之间有很大的区别。
应该有清单条目: Main-Class: MyApp
不带.class
Main-Class: MyApp
Use 采用
java -jar MyApp.jar
to run the main class in the jar 在罐子里跑主班
jar cfe MyApp.jar MyApp MyApp.class
java -jar MyApp.jar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.