无法使用 Jar 文件找到或加载主类
我正在尝试使用
@echo off
java -jar Test.jar
pause
随着
Manifest-Version: 1.0
Main-Class: classes.TestClass
在Jar目录下,解压后可以清晰的看到classesTestClass文件.
In the Jar directory, I can clearly see a classesTestClass file when I extract it.
classes.TestClass
确实有一个 public static void main(String[] args)
.
classes.TestClass
中的Package Deceleration是package classes;
Package Deceleration in classes.TestClass
is package classes;
但我仍然不断收到错误信息
But I still keep getting the error message
Could not find or load main class classes.TestClass
对于这个问题,我已经解决了所有我能找到的问题,但似乎没有任何帮助.
I've been through everything I've been able to find with this problem, and none of it seems to help.
我尝试编辑类路径、重做清单、安装新的 JRE.
I've tried editing the classpath, redoing the manifest, installing the new JRE.
我还应该做什么?
我是这样工作的:
TestClass.Java
package classes;
public class TestClass {
public static void main(String[] args) {
System.out.println("Test");
}
}
在命令行上使用 javac
生成 TestClass.class
.将 TestClass.class
放在文件夹 classes/
中.
Use javac
on the command line to produce TestClass.class
. Put TestClass.class
in a folder classes/
.
MANIFEST.MF
Manifest-Version: 1.0
Main-Class: classes.TestClass
然后运行
jar cfm test.jar MANIFEST.MF classes/
然后运行它
java -jar test.jar