jar 小程序类路径

发布于 2024-09-14 17:58:16 字数 1824 浏览 9 评论 0原文

我正在尝试将 JAR 文件添加到一个简单的 java 小程序中,该小程序可以用 HTML 打开。

这是我的编码:

<applet code="AgniCorpContactsApp.class" 
codebase="/agnicorpcontacts" width="100" height="100" 
archive="AgniCorpContactsApp.jar">
</applet> 

JAR 文件和所有类文件的位置为:C:\Documents and Settings\Owner\My Documents\NetBeansProjects\AgniCorpContacts\build\classes\

每当我尝试在 Internet Explorer 中运行该文件时出现此错误:

load: class AgniCorpContactsApp.class not found.
java.lang.ClassNotFoundException: AgniCorpContactsApp.class
 at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
 at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
 at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
 at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: \agnicorpcontacts\AgniCorpContactsApp\class.class (The system cannot find the path specified)
 at java.io.FileInputStream.open(Native Method)
 at java.io.FileInputStream.<init>(Unknown Source)
 at java.io.FileInputStream.<init>(Unknown Source)
 at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
 at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
 at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
 at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
 at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 ... 7 more
Exception: java.lang.ClassNotFoundException: AgniCorpContactsApp.class

我需要做什么才能解决此问题?是不是类路径有问题?

I am trying to add a JAR file to a simple java applet which can be opened has an HTML.

This is my coding:

<applet code="AgniCorpContactsApp.class" 
codebase="/agnicorpcontacts" width="100" height="100" 
archive="AgniCorpContactsApp.jar">
</applet> 

The location of the JAR file and all of the class files is: C:\Documents and Settings\Owner\My Documents\NetBeansProjects\AgniCorpContacts\build\classes\

Whenever I try to run the file in Internet explorer I get this error:

load: class AgniCorpContactsApp.class not found.
java.lang.ClassNotFoundException: AgniCorpContactsApp.class
 at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
 at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
 at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
 at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: \agnicorpcontacts\AgniCorpContactsApp\class.class (The system cannot find the path specified)
 at java.io.FileInputStream.open(Native Method)
 at java.io.FileInputStream.<init>(Unknown Source)
 at java.io.FileInputStream.<init>(Unknown Source)
 at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
 at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
 at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
 at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
 at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 ... 7 more
Exception: java.lang.ClassNotFoundException: AgniCorpContactsApp.class

What do I need to do in order to fix this? Is there a problem with the class path?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

扬花落满肩 2024-09-21 17:58:16

小程序启动器无法找到该类。这可能是因为您的小程序标签(如果您使用的是小程序标签)不正确。如果您使用多个类,您应该拥有小程序的代码库和代码属性。或者,您可以选择将所有类归档到一个可由小程序引用的 jar 归档文件中。有关详细信息,请参阅此处

The applet launcher cannot locate the class. This is probably because your applet tag (if you are using one) is not proper. You should have the codebase and code attributes for your applet if you are using multiple classes. Or optionally you can archive all the classes into a single jar archive which can be referenced by the applet. See here for details

说好的呢 2024-09-21 17:58:16

已经有一段时间了,但您需要从 Web 服务器提供小程序,并包含相对于 Web 服务器的 jar 文件路径。我认为您可以使用 sun 提供的工具(Applet Runner?)进行本地测试

Its been a while, but you need to serve your applet from a web server and include the jar file path relative to the webserver. I think you can do local testing using a tool sun delivers (Applet Runner?)

萌化 2024-09-21 17:58:16
<小程序代码=“AgniCorpContactsApp.class”>

删除 .class 后缀。 code 必须表示完整的限定类名(包括包),而不是文件名。

<applet code="AgniCorpContactsApp.class">

Remove the .class suffix. The code must denote the full qualified classname (including package), not the filename.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文