java jar 问题

来源:百度知道 编辑:UC知道 时间:2024/09/22 01:36:41
这是简单的 class 文件
public class A{
public static void main (String[] args) {
System.out.println("hello");
}
}
做成jar文件时遇到了问题
manifest.mf文件是这样配置的:
Manifest-Version: 1.0
Main-Class: A
Created-By: 1.6(Sun Microsystems Inc.)

cmd命令:jar cvfm A.jar manifest.mf A.class
执行命令成功生成了A.jar文件
问题就是双击A.jar文件不能运行,弹出一个类似警告的对话框

Could not find the main class. Program will exit.

我试就很多次,也试打包了其他的class文件.问题还是

Could not find the main class. Program will exit.

是否和环境变量有关?
在dos窗口下用java -jar A.jar命令运行 可以运行.
意思A.jar包 没错,错在那呢?

我自己写了个破打包工具,打包后可以运行...:b.. 要不要试试..

( ⊙ o ⊙ )是的,当然
!!!!!!!!!!!!!!!
用eclipse 右击项目-》export-》Java-》jar file-》next -》next-》选择main class类-》ok

用eclipse 右击项目-》export-》Java-》jar file-》next -》next-》选择main class类-》ok