Hi again, In the continuing saga of trying to get these applets up... I am trying to follow the directions in Head First Java for compiling and running with packages.
So MyProject has two directories, source and classes. Each of these has a directory called com which has a directory called rephunk which has all the .java or .class files in it. So far so good. However, I also have a set of classes that I've developed that is used by all 6 applets (Graph, GraphPanel, etc). So I put these all into a directory called myclasses with a similar directory structure.
When I try to compile the applet, I use a classpath to indicate where the shared classes are, so I type "javac -d ..\classes -cp .;c:\java\myclasses\source\com\rephunk\*.java"
However, then I get the following error :
"cannot access GraphPanel. bad class file: c:\java\myclasses\source\com\rephunk\GraphPanel.java file does not contain class GraphPanel Please remove or make sure it appears in the correct subdirectory of the classpath"
It doesn't complain about the other classes, and I can't find anything wrong with the GraphPanel.java file, which has always worked fine until now.
There are two problems here. First, you include source files in the classpath. That will not work - they need to be class files. Second, you specify the complete directory path, when you should be specifying the root of the class directory. So it should probably read "-cp .;c:\java\myclasses\classes".
Joined: Aug 19, 2005
I guess that's why its called a classpath, not a sourcepath! I'm embarrassed to say I never thought about it.
For the sake of completeness, I also found I had left the package statement out of one of the files (not the one being complained about, but still...)