This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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: 9643
42
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: 9643
42
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: 9643
42
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
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!