wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes package does not exist error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "package does not exist error" Watch "package does not exist error" New topic
Author

package does not exist error

Preet Dhillon
Greenhorn

Joined: May 20, 2008
Posts: 24
I am going through chapter 1 of SCJP for Java 5 by By Kathy Sierra and Bert Bates.

I am trying out the Protected members sample code on page 34-35. I have a folder called Ex2. Ex2 has two subfolders called certification and other as in the code sample. Folder "certification" holds the Parent.java, which compiles fine. Folder "other" holds Child.java. When I go to compile Child.java, I get 3 errors starting with package certification does not exist.

Here is the code:


and



I follow the following order when I compile the files-

set CLASSPATH=h:\Java\SCJP\Ex2
cd c:\Program Files\Java\jdk1.6.0_06\bin
javac h:\Java\SCJP\Ex2\certification\Parent.java
javac h:\Java\SCJP\Ex2\other\Chile.java

I am not sure what I am doing wrong...
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9302
    
  17

kanwal try to use these commands

set CLASSPATH=h:\Java\SCJP\Ex2
set PATH=%PATH%;c:\Program Files\Java\jdk1.6.0_06\bin
cd h:\java\SCJP\Ex2
javac certification\Parent.java
javac other\Chile.java

If this doesn't work please tell...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Preet Dhillon
Greenhorn

Joined: May 20, 2008
Posts: 24
Sorry! it did not work.

I get the following message:
javac: file not found: certification\Parent.java
Usage: javac <options> <source files>
use-help for a list of possible options


Just to let you know that I don't have administrator priviliges on my Windows XP computer. I wonder if that causes me to not being able to set path. I could arrange to have the pathe variable added by an administrator if that could solve my problems.

Thanks.
Preet Dhillon
Greenhorn

Joined: May 20, 2008
Posts: 24
Actually, I just checked the paths by typing the "path" command and path to "c:\Program files\Java\jdk1.6.0_06\bin exists.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9302
    
  17

I just saw that you are invoking

javac other\Chile.java

Is that a typo or you are actually using that command???
Preet Dhillon
Greenhorn

Joined: May 20, 2008
Posts: 24
I am not using it at command line - It was just a typo when I posted the message
Preet Dhillon
Greenhorn

Joined: May 20, 2008
Posts: 24
It's working now - I've found out what I was doing wrong.



set CLASSPATH=h:\Java\SCJP\Ex2
set PATH=%PATH%;c:\Program Files\Java\jdk1.6.0_06\bin
cd h:\java\SCJP\Ex2


I was trying to run Javac from c:>

javac certification\Parent.java
javac other\Chile.java


Once I changed to H: drive, both files compiled.

Thanks for your help!
Preet Dhillon
Greenhorn

Joined: May 20, 2008
Posts: 24
It's very frustrating but I can't run these files. I've tried many options.

1. h:\Java\SCJP\Ex2> java other\Child
2. h:\Java\SCJP\Ex2\other> java Child
3. I've tried to change the Classpath to h:\Java\SCJP\Ex2\other

I get the same error - Exception in thread "main" java.lang.NoClassDefFoundError
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9302
    
  17

bro you class Child has no main method as per the code you posted

Preet Dhillon
Greenhorn

Joined: May 20, 2008
Posts: 24
It's straight from the book (page 34-35). I guess you are supposed to modify them before you can try and test them
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: package does not exist error