无法加载主类清单属性
我创建了一个在网络浏览器上运行的简单小程序。我通过在命令提示符中运行“C:\Program Files\Java\jdk1.6.0_21\bin\jar”cfv Project7Applet.jar *.class 创建 Jar 文件,然后当我尝试运行该 jar 文件时,出现“失败”加载主类清单属性错误”但是我不明白为什么会发生这种情况,因为在命令提示符中,当我创建 jar 文件时,它说
added manifest
adding: Project7Applet.class.....
adding: Project7Panel.class...
这是我的 .html 文件
<html>
<head>
<title>Right Triangles</title>
</head>
<body>
<h1>Right Triangles</h1>
<!--"CONVERTED_APPLET"-->
<!-- HTML CONVERTER -->
<object
classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codebase = "http://java.sun.com/update/1.6.0/jinstall-6u21-windows-i586.cab#Version=6,0,0,7"
WIDTH = 240 HEIGHT = 175 >
<PARAM NAME = CODE VALUE = "Project7Applet.class" >
<PARAM NAME = ARCHIVE VALUE = "Project7Applet.jar" >
<param name = "type" value = "application/x-java-applet;version=1.6">
<param name = "scriptable" value = "false">
<comment>
<embed
type = "application/x-java-applet;version=1.6" \
CODE = "Project7Applet.class" \
ARCHIVE = "Project7Applet.jar" \
WIDTH = 200 \
HEIGHT = 125
scriptable = false
pluginspage = "http://java.sun.com/products/plugin/index.html#download">
<noembed>
<p>This applet requires version 1.5 or later of Java.</p>
</noembed>
</embed>
</comment>
</object>
<!--
<APPLET CODE = "Project7Applet.class" ARCHIVE = "Project7Applet.jar" WIDTH = 240 HEIGHT = 175>
<p>This applet requires version 1.5 or later of Java.</p>
</APPLET>
-->
<!--"END_CONVERTED_APPLET"-->
</body>
</html>
I created a simple applet to run on a web browser. i create Jar file by running "C:\Program Files\Java\jdk1.6.0_21\bin\jar" cfv Project7Applet.jar *.class in a command prompt and then when i try to run the jar file i get the "failed to load main-class manifest attribute error" However i don't understand why this happens because in the command prompt when i create the jar file it says
added manifest
adding: Project7Applet.class.....
adding: Project7Panel.class...
here's my .html file
<html>
<head>
<title>Right Triangles</title>
</head>
<body>
<h1>Right Triangles</h1>
<!--"CONVERTED_APPLET"-->
<!-- HTML CONVERTER -->
<object
classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codebase = "http://java.sun.com/update/1.6.0/jinstall-6u21-windows-i586.cab#Version=6,0,0,7"
WIDTH = 240 HEIGHT = 175 >
<PARAM NAME = CODE VALUE = "Project7Applet.class" >
<PARAM NAME = ARCHIVE VALUE = "Project7Applet.jar" >
<param name = "type" value = "application/x-java-applet;version=1.6">
<param name = "scriptable" value = "false">
<comment>
<embed
type = "application/x-java-applet;version=1.6" \
CODE = "Project7Applet.class" \
ARCHIVE = "Project7Applet.jar" \
WIDTH = 200 \
HEIGHT = 125
scriptable = false
pluginspage = "http://java.sun.com/products/plugin/index.html#download">
<noembed>
<p>This applet requires version 1.5 or later of Java.</p>
</noembed>
</embed>
</comment>
</object>
<!--
<APPLET CODE = "Project7Applet.class" ARCHIVE = "Project7Applet.jar" WIDTH = 240 HEIGHT = 175>
<p>This applet requires version 1.5 or later of Java.</p>
</APPLET>
-->
<!--"END_CONVERTED_APPLET"-->
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设当您双击运行 jar 时出现错误:
然后您应该有一个包含以下内容的 manifest.mf 文件:
Main-Class 之后有一个 CRLF。
然后创建你的 jar
现在你有一个可执行的 jar 了。
如果您在浏览器中遇到主类清单错误,请发表评论。
I am assuming that your error is coming when you are double clicking of running your jar as:
Then you should have a manifest.mf file with following contents:
There is a CRLF after Main-Class.
Then create your jar as
Now you have an executable jar.
Please comment if you are facing the main-class manifest error within your browser.