Hi, I have the following applet which works on my localhost server but when I upload it to my online server then the Java console spits out an error saying the following:

Exception in thread "thread applet-viewer.class-1" java.lang.NoClassDefFoundError: viewer$1 (wrong name: viewer)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(Unknown Source)
	at java.lang.ClassLoader.defineClass(Unknown Source)
	at java.security.SecureClassLoader.defineClass(Unknown Source)
	at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
	at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
	at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
	at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at viewer.downloadthread(viewer.java:465)
	at viewer.init(viewer.java:205)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Exception in thread "thread applet-viewer.class-2" java.lang.NoClassDefFoundError: viewer$1
	at viewer.downloadthread(viewer.java:465)
	at viewer.init(viewer.java:205)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

The strange thing is when I run it from http://localhost/myfolder it doesn't have any of these errors at all. Below is the html used for the applet as I believe it is html related.

<applet code="viewer.class" archive="l.png,r.png,btn.png,viewer$1.class" width="689" height="456"> 
        <PARAM NAME="domain" VALUE="1001d01001dc1001e81001e41001aa10016910015e1001951001cb1001d71001e01001e41001d71001cd1001d11001c81001d21001dc1001da1001e21001e31001d71001dd1001ed1001f01001e01001d41001d410019710018f1001d61001a210015f1001601001911001d21001dc10019c1001951001d51001e11001d41001cb1001cd1001c81001c91001d310019d1001901001d31001d51001cb1001d11001df1001db100194"> 
        <PARAM NAME="fileid" VALUE="3"> 
        <PARAM NAME="numfiles" VALUE="48"> 
        <PARAM NAME="paperid" VALUE="0"> 
        <PARAM NAME="appid" VALUE="1001d51001d410019c1001981001c81001d91001dd1001de1001ed1001ef1001e81001eb1001b11001691001651001a31001e11001dd1001d91001d91001da1001a010016710016b10016610015d10015e10016410016310016310016c10017010016d10016f10016d100164">

Also the Java applet is made of 2 files (archive.class & archive$1.class) plus a few pictures. I have never dealt with multiple class files before so could somebody point out how I am meant to include multiple class files in an applet properly.

Thankyou.

Do not use ClassName.class attribute value of code and archive attribute value should be .jar file. So, you need to create Java Archive (.jar) that contains applet classes and other resources.

<applet code="package.ClassName" archive="myresource.jar" width="689" height="456"> 
...
</applet>

PS: Class viewer$1 is an anonymous inner class which will be automatically loaded by the class loader.

commented: Best reply ever +12

THANKYOU SO MUCH!!!
You have solved two problems in one reply.
One problem was I was starting to get a long list of files which you stated could be put into a .jar file and the other was that Java refused to load the main class which after implementing the .jar file it seem to fix itself. Thankyou so much as it has saved me so many troubles. :)

commented: I'm glad you got it working. +14
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.