Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

package does not exist error  RSS feed

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Sheriff
Posts: 9613
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Preet Dhillon
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9613
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not using it at command line - It was just a typo when I posted the message
 
Preet Dhillon
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9613
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bro you class Child has no main method as per the code you posted

 
Preet Dhillon
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's straight from the book (page 34-35). I guess you are supposed to modify them before you can try and test them
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!