how to make an applet load user-defined packages??

M

Mark_Galeck

Hello, I can compile an applet that uses packages I define, but it
will not run, because, it does not want to access the class files in
the packages directories (only its own). I can run and load
everything if I put all the code in one directory and don't use
packages. I can use applications with my own packages in their own
directories. But I can't use applets with my own packages. The
applet ignores CLASSPATH so that does not work.

There must be a way to run applets composed of multiple packages.
How?

Mark
 
K

Knute Johnson

Mark_Galeck said:
Hello, I can compile an applet that uses packages I define, but it
will not run, because, it does not want to access the class files in
the packages directories (only its own). I can run and load
everything if I put all the code in one directory and don't use
packages. I can use applications with my own packages in their own
directories. But I can't use applets with my own packages. The
applet ignores CLASSPATH so that does not work.

There must be a way to run applets composed of multiple packages.
How?

Mark

Your class files must be in a directory with the same name as the
package. When you create the .jar files, the individual files must be
in the same directories in the .jar file as well. Whenever you refer to
your classes you must refer to them by their full names (eg.
com.Marksfiles.applet.MyApplet).

You problem is most likely related to directories or .jar not being
correct. I use a standard directory structure for all my Java programs,
it looks like com.knutejohnson.packagename.ClassName. When I compile my
programs, I start the compile from above the com directory. This way
the compiler can see all of my classes no matter what package they are
in. The jar program is run from there for the same reasons. All this
makes it really simple to get all the package name/directories to be in
the right place.

In your case you might just be able to get it to run by being in the
directory above your package root directory.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top