[英]Can't launch my first Java program by jar file
I just made my first Java program and it worked perfectly, when I launched it by 'IDEA'. 当我由“ IDEA”启动它时,我刚刚编写了自己的第一个Java程序,并且运行良好。 Then I wanted to create an executable file to launch it separately.
然后,我想创建一个可执行文件以单独启动它。 'IDEA' helped me create a jar file with this content inside it:
“ IDEA”帮助我创建了一个包含以下内容的jar文件:
Some classes (*.class files). 一些类(* .class文件)。
Folder META-INF with MANIFEST.MF in it. 其中包含MANIFEST.MF的META-INF文件夹。 MANIFEST.MF has only 2 lines: version info and "Main-Class: ru.nikolski.2048.main".
MANIFEST.MF只有两行:版本信息和“ Main-Class:ru.nikolski.2048.main”。
When I double click on the jar file, nothing happens. 当我双击jar文件时,什么也没有发生。 When I launch the jar file by 'IDEA', it writes the following:
当我通过“ IDEA”启动jar文件时,它会写以下内容:
"C:\Program Files\Java\jdk1.7.0_51\bin\java" -Dfile.encoding=windows-1251 -jar C:\Users\Osn\IdeaProjects\Game2048\out\artifacts\Game2048_jar\Game2048.jar
Error: Could not find or load main class ru.nikolski.2048.main
I tried to make folder ru/nikolski/2048 inside the jar file, and put all *.class files in it, but it didnt help, I got the same error. 我试图在jar文件中放入ru / nikolski / 2048文件夹,并将所有* .class文件放入其中,但是它没有帮助,我遇到了同样的错误。
What am I doing wrong? 我究竟做错了什么?
I solved the problem just correcting the line in MANIFEST.MF: 我只通过更正MANIFEST.MF中的行就解决了这个问题:
Main-Class: Main
as my class with main method has the name 'Main'. 因为我的带有main方法的类的名称为“ Main”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.