简体   繁体   中英

JApplet throws ClassNotFoundException from signed jar

I've built an applet (from JApplet) that consumes several other jar files. I've signed my jar that contains the main class and included all of the jars I need (I think). However, no matter what I try, I consistently get "java.lang.ClassNotFoundException: newposting" where 'newposting' is the main class within my signed jar. I'm using the following html for this:

<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. I've tried several combinations of path specifications. I've also tried using jnlp but get the same error. 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.

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.

If so you still have 2 possibilities.

Are you sure that your class is indeed called newposting ? Lowercase? In default package? Note: this must be fully qualified class name .

Next, test that your jar is indeed available for browser. To do so just copy and paste the jar name to browser prepending it with your URL. For example if HTML is available under http://myhost/myapp/mypage.html try URL http://myhost/myapp/HartfordRowingNewPosting.jar .

BTW what does parameter codebase mean? 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 . This attribute is typically . : <applet codebase="." that means "download jars from current directory". This is the same as to say java -cp . when running java from command line.

BTW, do you know that applets were almost obsolete about 10 years ago? Moreover as far as I can see you included MySql JDBC driver into your class path. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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