Hello,all I just started my SCJD exam. I began my study with "The Sun Certified Java Developer Exam with J2SE 1.4". When I tried to compile codes from the book. I encountered "cannot resolve the symbol" error. Here is the structure: Three files: DVD.java DVDDatabase.java DOSClient.java in my working directory C:\sunCert\sampleproject\db I could successfully compile these files using "javac *.java". But I could not compile them individually. I could successfully compile DVD.java. But there was an error for DVDDatabase.java and DOSClient.java which had reference to DVD class. I thought it might be classpath problem, so I tried the following methods: 1. javac -classpath C:\sunCert\sampleproject\db\ DVDDatabase.java 2. 1. javac -classpath . DVDDatabase.java 3. make classes directory under db dir, then compile DVD.java into classes, then javac -d classes DVDDatabase.java None of these succeeded. The same error "cannot resolve the symbole" occured. The strange thing is that when I moved these files into C:\sunCert dir, I could compile them individually and I didn't even have to specify classpath. How could this happen? One more question about SCJD. Can I use j2sdk1.4.2_02 for the project? I found my java version is "build 1.4.2_02-b03". Does that "b" mean beta? I am the beginner of Java, but I'd like to learn more about it. I would appreciate your reply. Thanks
Hi Leon, Welcome to JavaRanch. I suspect that your problem with compiling the code is because each source file identifies that it is in the package "sampleproject.db". So when the DVDDatabase class refers to the DVD class, the Java compiler goes to look for it in the directory .\sampleproject\db\ When you copied the java files into the suncertify directory, you were indirectly addressing this issue. When you tried to compile DVDDatabase.java, the compiler ignored the DVD.java file in the suncertify directory, and went and looked for it in the sampleproject\db\ directory, where it found it. It then compiled happily. What you could try doing is:
remove all *.java and *.class files from the c:\suncert directory
go to the suncert directory
Run the command
And see if that works (I don't run MS Windows, so I can't verify that myself).
I would recommend that you set up a basic structure for your files such that your source code and compiled code are in different directories (and eventually your API documentation is in it's own directory and so on). Max (Mehran) talks about this on pages 17 & 18.
One more question about SCJD. Can I use j2sdk1.4.2_02 for the project? I found my java version is "build 1.4.2_02-b03". Does that "b" mean beta?
Yes you can use that. Sun use the b to designate the "build" of the release, not for "beta". Regards, Andrew
Thanks, Andrew, You are right, the problem is my incorrect structure. Once I have right structure for my files, everything is fine. I searched the past posts, but I couldn't find the Max(Mehran)'s post about the basic structure. Could you kindly give me the direction? Thank you Leon