简体   繁体   English

JApplet从签名的jar中抛出ClassNotFoundException

[英]JApplet throws ClassNotFoundException from signed jar

I've built an applet (from JApplet) that consumes several other jar files. 我建立了一个applet(来自JApplet),它使用了其他几个jar文件。 I've signed my jar that contains the main class and included all of the jars I need (I think). 我已经签名了包含主类的jar,并包含了我需要的所有jar(我认为)。 However, no matter what I try, I consistently get "java.lang.ClassNotFoundException: newposting" where 'newposting' is the main class within my signed jar. 但是,无论我尝试什么,我都会得到“ java.lang.ClassNotFoundException:newposting”,其中“ newposting”是我签名的jar中的主要类。 I'm using the following html for this: 我为此使用以下html:

<p><applet code="newposting" 
archive="HartfordRowingNewPosting.jar, 
javax.mail.jar, 
jcalendar-1.4.jar, 
junit-4.6.jar, 
jgoodies-common-1.2.0.jar, 
jgoodies-looks-2.4.1.jar, 
mysql-connector-java-5.1.25-bin.jar" 
width="500" height="850">
<param name="permissions" value="sandbox" /> 
<param name="codebase" value="HartfordRowingNewPosting.jar" /> 
</applet></p>

The jars and html are all located in the same folder on the server. jar和html都位于服务器上的同一文件夹中。 I've tried several combinations of path specifications. 我尝试了几种路径规范的组合。 I've also tried using jnlp but get the same error. 我也尝试过使用jnlp,但得到相同的错误。 I've been frustrated with this on and off for the last month or so. 在过去一个月左右的时间里,我一直对此感到沮丧。 Can someone shed some light on this? 有人可以阐明这一点吗?

The fact the ClassNotFoundException is thrown when loading your main class means that either your class cannot be read from jar or your jar cannot be found. 加载主类时抛出ClassNotFoundException的事实意味着无法从jar读取类或找不到jar。

I hope that your verified that your clas is indeed in jar. 我希望您能验证自己的确在罐子里。 If not try it. 如果没有尝试。 Just to be sure try to use unsigned jar and see that you have exactly the same error. 只是要确保尝试使用未签名的jar并查看是否存在完全相同的错误。

If so you still have 2 possibilities. 如果是这样,您仍有2种可能性。

Are you sure that your class is indeed called newposting ? 您确定您的课程确实称为新newposting吗? Lowercase? 小写? In default package? 在默认包中? Note: this must be fully qualified class name . 注意:这必须是完全合格的类名

Next, test that your jar is indeed available for browser. 接下来,测试您的jar是否确实可用于浏览器。 To do so just copy and paste the jar name to browser prepending it with your URL. 为此,只需将jar名称复制并粘贴到浏览器中,并在其前面加上您的URL。 For example if HTML is available under http://myhost/myapp/mypage.html try URL http://myhost/myapp/HartfordRowingNewPosting.jar . 例如,如果可以在http://myhost/myapp/mypage.html下找到HTML,请尝试使用URL http://myhost/myapp/HartfordRowingNewPosting.jar

BTW what does parameter codebase mean? BTW参数codebase是什么意思? Is it your application level parameter? 是您的应用程序级别参数吗? I am not sure but make sure that this does not confuse browser with attribute codebase supported by tag applet . 我不确定,但是请确保这不会使浏览器与标签applet支持的属性codebase混淆。 This attribute is typically . 此属性通常为. : <applet codebase="." <applet codebase="." that means "download jars from current directory". 这意味着“从当前目录下载jar”。 This is the same as to say java -cp . 这与说java -cp .相同java -cp . when running java from command line. 从命令行运行Java时。

BTW, do you know that applets were almost obsolete about 10 years ago? 顺便说一句,您知道小程序在10年前几乎已经过时了吗? Moreover as far as I can see you included MySql JDBC driver into your class path. 而且据我所知,您将MySql JDBC驱动程序包括在类路径中。 You should understand that this will not work in most cases because typically there is a firewall that does not allow JDBC protocol between clients and server. 您应该了解,在大多数情况下这是行不通的,因为通常存在不允许客户端和服务器之间使用JDBC协议的防火墙。

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

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