Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exercise 2.1

 
Philip Washburn
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was unable to get the code for Apple.java to compile in exercise 2.1 of the Sun Certified Programmer & Developer study guide:
Apple.java
import food.Fruit;
public class Apple extends Fruit{}
Fruit.java (in subdirectory food)
package food;
public abstract class Fruit{}

The compiler say "package food does not exist". What am I doing wrong?
 
Richard Quist
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
assuming you're in the directory that has Apple.java and food is a subdirectory of it, this should work:
javac -classpath . Apple.java
 
Giuoco Krag
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Philip Washburn:
package food;
public abstract class Fruit{}

The compiler say "package food does not exist". What am I doing wrong?

Also, make sure your directory structure is properly set up. Depending on where you compile your code, I think your source must be in a directory named food.
? does this make sense ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic