• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Excercise 1-1 from Kathy Sierra, Bert Bates Study Guide

 
Preet Dhillon
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am really embarrassed to report that I am stuck on Exercise 1-1

I get the following error when I go to compile Apple.java:
Package food does not exist.


I have my JDK installed on my c rogram files\Java\jdk1.6.0_06\bin
My class files are located in: H:\ Java\SCJP\Apple.java and H:\ Java\SCJP\food\Fruit.java and Fruit.class

I have CLASSPATH set to h:\Java\SCJP

Any ides what I'm doing wrong.
Thanks in advance
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before I start guessing could you post the code you are using in it's entirety as well?
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kanwal everything looks fine as far as you have posted. Please post the exact steps through which you compiled the files...
 
Klebson Carneiro
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After 3 years, he did not reply, but I got stuck in the same problem :P

1st file: Fruit.java


Compiled with no errors, through:
javac Fruit.java

2nd file: Apple.java


Does not compile, through:
javac Apple.java

Error:
Apple.java:1: package food does not exist
import food.Fruit;

Both .java files are in the same folder
 
Klebson Carneiro
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The solution is in this same forum:

http://www.coderanch.com/t/269257/java-programmer-SCJP/certification/Exercise

1st:
javac -d . Fruit.java
(food folder is created with Fruit.class inside)

then
javac -classpath . Apple.java
or
add . to CLASSPATH and
javac Apple.java
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic