Using classes in a java applet that resides outside of the classpath
Posted on 2001-09-07
Why am I unable to declare and use classes (that reside in files in my classpath) in my Java applet (a file that resides outside of the classpath)? I can do this if my Java applet source file resides in the classpath, however, if it is outside of the classpath I have problems.
My src file has this in it:
Database db = new Database();
I can compile my code using the following:
javac -classpath c:\web\WEB-INF\classes c:\web\gui\testapplet.java
There is no error on compile. When I attempt to run my applet in a browser, I get an error "Start: applet not initialized" and consequently the applet does not display. If I remove my class declaration compiles, runs, and displays without error. I know it's not a problem with the class itself because I am able to use the class in other Java code (that resides inside of the classpath). Also I get the same initialization error problem if I try to use other classes (that reside in the classpath) in my applet (that resides outside the classpath).
Is there some special way you have to declare classes when your source code is outside of the classpath? Or is there some special way to compile the code? What am I doing wrong? It seems like this shouldn't be so hard to do.