Applet with multiple class files
I'm new to java and I have made a sample applet with one class (in the default package) and have been able to load that in a browser. However I made a program that has one package (called applet) and under there are 2 class files. I have run the program in eclipse and it works fine, however when I copy both the .class files to my web server and do the embed tag with the code="MainFile.class" it won't work. Should it? or is there something special you must do when you have multiple class files.
[507 byte] By [
metzgerha] at [2007-11-27 5:55:38]

# 3
seems u didn't get my point.
it is not possible to find a solution until we know the exact problem,i.e. the exact exception the jvm throws up.
you should try this:
put all your class files and the webpage with the applet code embed into it in a common directory, say, Desktop.
open the webpage using internet explorer.
on the ie menubar find the 'tools' menu.
you will see a "Sun Java Console" menu item there, if ur browser is java enabled.
open the console and look for the exact exception the JVM throws up.
# 4
Alright. Heres what it says:
Java Plug-in 1.6.0
Using JRE version 1.6.0 Java HotSpot(TM) Client VM
-
c:clear console window
f:finalize objects on finalization queue
g:garbage collect
h:display this help message
l:dump classloader list
m:print memory usage
o:trigger logging
p:reload proxy configuration
q:hide console
r:reload policy configuration
s:dump system and deployment properties
t:dump thread list
v:dump thread stack
x:clear classloader cache
0-5: set trace level to <n>
-
java.lang.NoClassDefFoundError: ParaGrapher (wrong name: applet/ParaGrapher)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:178)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:127)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:618)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:778)
at sun.plugin.AppletViewer.createApplet(AppletViewer.java:2045)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:707)
at sun.applet.AppletPanel.run(AppletPanel.java:361)
at java.lang.Thread.run(Thread.java:619)
java.lang.NoClassDefFoundError: ParaGrapher (wrong name: applet/ParaGrapher)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:178)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:127)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:618)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:778)
at sun.plugin.AppletViewer.createApplet(AppletViewer.java:2045)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:707)
at sun.applet.AppletPanel.run(AppletPanel.java:361)
at java.lang.Thread.run(Thread.java:619)
ParaGrapher is the name of my applet.