Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting an error package ..... does not exist

843810Jul 9 2008 — edited Jul 9 2008
Hi,

I am trying to learn Java through Sams Teach Yourself Java 6. In the book it asked me to create a directory called

c:\dev\java\org\cadenhead\ecommerce

I have added the c:\dev\java into the CLASSPATH variable in Vista

The program I am trying to compile is in another directory called c:\JavaWrk

I am getting an error when I compile the code, the first error is
------------------------------------------------------------------------------
GiftShop.java:1: package org.cadenhead does not exist
import org.cadenhead.ecommerce;
^
-------------------------------------------------------------------------------

The rest of the error is because the program is trying to invoke methods that are in the class file located in the package subdirectory.

Here is the program I am trying to compile
--------------------------------------------------------------------------------
import org.cadenhead.ecommerce;

public class GiftShop {
public static void main(String[] args) {
Storefront store = new Storefront();
store.addItem("C01", "MUG", "9.99", "150");
store.addItem("C02", "LG MUG", "12.99", "82");
store.addItem("C03", "MOUSEPAD", "10.49", "800");
store.addItem("C04", "T SHIRT", "16.99", "90");
store.sort();

for (int i = 0; i < store.getSize(); i++) {
Item show = (Item)store.getItem(i);
System.out.println("\nItem ID:" + show.getId() +
"\nName:" + show.getName() +
"\nRetail Price: $" + show.getRetail() +
"\nPrice: $" + show.getPrice() +
"\nQuantity: " + show.getQuantity());
}
}
}
--------------------------------------------------------------------------------

I also tried compiling the file using the command "javac -cp c:\dev\java GiftShop.java" adn still gets the error.

I did not want to leave the chapter without resolving the issue. Any help will be much appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 6 2008
Added on Jul 9 2008
6 comments
1,066 views