File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes about compilation and JVM version Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "about compilation and JVM version" Watch "about compilation and JVM version" New topic

about compilation and JVM version

Leon Chin

Joined: Dec 03, 2003
Posts: 2
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:
in my working directory
I could successfully compile these files using "javac *.java". But I could not compile them individually. I could successfully compile But there was an error for and 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\
2. 1. javac -classpath .
3. make classes directory under db dir, then compile into classes, then javac -d classes
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.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11776

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, the compiler ignored the 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

    The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
    Leon Chin

    Joined: Dec 03, 2003
    Posts: 2
    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
    Terry Martinson
    Ranch Hand

    Joined: Oct 18, 2003
    Posts: 293
    I think Andrew is talking about p. 17 and 18 of the actual Max book. Section "Organizing a Project" in Chapter 2.

    I agree. Here's the link:
    subject: about compilation and JVM version
    It's not a secret anymore!