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]
# 1
Could you please elaborate what is the error message that shows up?Try the Sun Java Console in the Internet Explorer tools menu.
Shashank@iitba at 2007-7-12 16:24:44 > top of Java-index,Desktop,Core GUI APIs...
# 2
Sure. It freezes.
metzgerha at 2007-7-12 16:24:44 > top of Java-index,Desktop,Core GUI APIs...
# 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.

Shashank@iitba at 2007-7-12 16:24:44 > top of Java-index,Desktop,Core GUI APIs...
# 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.

metzgerha at 2007-7-12 16:24:44 > top of Java-index,Desktop,Core GUI APIs...
# 5
I got it working but I would like to understand why. What I did was remove the file out of the the package I made and but it in the base directory (The "default package") and removed the package blahblah; from the top of each .java file. Why should this matter? thanks.
metzgerha at 2007-7-12 16:24:44 > top of Java-index,Desktop,Core GUI APIs...
# 6
congs!!well...the fact is that i myself am a novice....for not more than one month in this language...so u c....lets both wait for someone with a better understanding ;) !!!cheers!
Shashank@iitba at 2007-7-12 16:24:44 > top of Java-index,Desktop,Core GUI APIs...