ClassNotFoundException Java 小程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25101628/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 07:20:35  来源:igfitidea点击:

ClassNotFoundException Java Applet

javaappletsyntax-errorjapplet

提问by Sticky

I get the ClassNotFoundException error when I make my html file with the code and jar file. Not sure why. Here's what I have:

当我使用代码和 jar 文件制作我的 html 文件时,我收到 ClassNotFoundException 错误。不知道为什么。这是我所拥有的:

 <html>
<head>
<title>
Test Applet
</title>
</head>
<body>
<h2>Test Applet</h2>
<applet
code="Testing.class"
archive="myTestJar.jar" 
width=550 height=300>
</applet>
</body>
</html>

I simply have the class in a jar file and tried to reference using archive but it doesn't work.

我只是将类放在一个 jar 文件中,并尝试使用存档进行引用,但它不起作用。

采纳答案by Deepanshu J bedi

try this

试试这个

<applet code=Testing.class
        archive="myTestJar.jar"
        width=550 height=300>
</applet>

The class has your main()I assume, the jar is the entire thing.

班级有你的main()我假设,罐子是整个事情。

if,you're not taking packages into consideration. For instance, if the package is myPackage.vol3 then the line should read

如果,您没有考虑包裹。例如,如果包是 myPackage.vol3,则该行应为

<applet code="myPackage.vol3.Testing.class" archive="myTestJar.jar"

and put the html file in the project folded "INSIDE" the project folder.

并将html文件放在项目折叠的“INSIDE”项目文件夹中。