问题描述
我可以在Windows和Mac OS X上干净地构建我的应用程序,但在Windows上尝试运行应用程序时,我得到了关于我的主类的类找不到异常
I can build my application cleanly on windows and Mac OS X but on windows when i try to run the application i get a class not found exception about my main class
主要找不到4美元。
类就在那里,它构建得很干净。为什么不能找到类文件?
Jar适用于OS X.
class is there and it build cleanly. why can't it locate the class file?Jar works in OS X.
Jar的创建方式如下。
Jar is created like the following.
<target name="jar" depends="">
<jar destfile="build/application.jar" >
<manifest>
<attribute name="Built-By" value="Hamza"/>
<attribute name="Main-Class" value="application"/>
</manifest>
<fileset dir="build">
<include name="**/*.class"/>
<include name="**/*.png"/>
<exclude name="**/*.jar"/>
</fileset>
</jar>
</target>
我可以在OS X上运行它而没有任何错误,但在Windows中我得到类未找到异常。
i can run it without any errors on OS X but in Windows i get class not found exceptions.
推荐答案
Main-Class属性是否真的设置为application?
Is the Main-Class attribute really set to "application"?
Main-Class应指明您要运行的类的相对路径,例如myPackage.Application,或简称为Main。
Main-Class should indicate the relative path to the class you want to run, e.g. "myPackage.Application", or simply "Main".
这篇关于Java Jar类未找到异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!