简体   繁体   English

jar applet类路径

[英]jar applet classpath

I am trying to add a JAR file to a simple java applet which can be opened has an HTML. 我试图将JAR文件添加到可以打开的具有HTML的简单Java小程序中。

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\\ JAR文件和所有类文件的位置为: 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: 每当我尝试在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

What do I need to do in order to fix this? 为了解决这个问题,我需要做什么? Is there a problem with the class path? 类路径有问题吗?

The applet launcher cannot locate the class. 小程序启动器无法找到该类。 This is probably because your applet tag (if you are using one) is not proper. 这可能是因为您的applet标记(如果使用的是不正确)。 You should have the codebase and code attributes for your applet if you are using multiple classes. 如果使用多个类,则应该具有applet的代码库和代码属性。 Or optionally you can archive all the classes into a single jar archive which can be referenced by the applet. 或者,可以选择将所有类归档到一个jar归档文件中,该applet可以引用该归档文件。 See here for details 详情请看这里

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. 已经有一段时间了,但是您需要从Web服务器提供applet,并包含相对于Web服务器的jar文件路径。 I think you can do local testing using a tool sun delivers (Applet Runner?) 我认为您可以使用sun提供的工具进行本地测试(Applet Runner?)

 <applet code="AgniCorpContactsApp.class"> 

Remove the .class suffix. 删除.class后缀。 The code must denote the full qualified classname (including package), not the filename. code必须表示完整的合格类名(包括软件包),而不是文件名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM