Help! Don't know why this source won't compile!

Hey guys, i'm new to the java scene. I just picked up a book about a week ago ("Sam's Teach Yourself Java 2") I'm on the 6th lesson of the book, learning about "Packages" (ie. java.awt).
The book contains compilable source code on a disk that comes with the book.
I'm stumped with the example i'm currently working on, and i've tried everything in my limited knowledge of java to solve the problem, but I can't. The example involves 2 seperate java text files.
package org.cadenhead.ecommerce;
import java.util.*;
public class Item implements Comparable {
    private String id;
    private String name;
    private double retail;
    private int quantity;
    private double price;
    Item(String idIn, String nameIn, String retailIn, String quanIn) {
        id = idIn;
        name = nameIn;
        retail = Double.parseDouble(retailIn);
        quantity = Integer.parseInt(quanIn);
        if (quantity > 400)
            price = retail * .5D;
        else if (quantity > 200)
            price = retail * .6D;
        else
            price = retail * .7D;
        price = Math.floor( price * 100 + .5 ) / 100;
    public int compareTo(Object obj) {
        Item temp = (Item)obj;
        if (this.price < temp.price)
            return 1;
        else if (this.price > temp.price)
            return -1;
        return 0;
    public String getId() {
        return id;
    public String getName() {
        return name;
    public double getRetail() {
        return retail;
    public int getQuantity() {
        return quantity;
    public double getPrice() {
        return price;
and this one..
package org.cadenhead.ecommerce;
import java.util.*;
public class Storefront {
    private LinkedList catalog = new LinkedList();
    public void addItem(String id, String name, String price,
        String quant) {
        Item it = new Item(id, name, price, quant);
        catalog.add(it);
    public Item getItem(int i) {
        return (Item)catalog.get(i);
    public int getSize() {
        return catalog.size();
    public void sort() {
        Collections.sort(catalog);
Now the example has to do with creating a package "org.cadenhead.ecommerce"
So I placed both source files in a folder in what I believe is my classpath. (C:\program files\java\jdk1.5.0_05\ lib\org\cadenhead\ecommerce)
The Item class compiles, but the Storefront won't. Every class i've made this far has had no problems compiling, and I doubt that there is an error in the code since it is straight from the book. When I try to compile, i get 4 errors, all of which look similar to this:
Storefront.java:15: cannot find symbol
symbol : class Item
location : class.org.cadenhead.ecommerce.Storefront
public Item getItem(int i) {
^
Can anyone help me out and figure out what's wrong here? I'm really confused about why it doesn't seem to be able to find the Item class. I'm kind of stuck in the book since I can't figure this out and I wanted to make sure everything was configured right. I set the classpath in the "Enviroment Variables" folder (windows XP) to .;C:\Program Files\Java\jdk1.5.0_05\lib\tools.jar
but to no avail...
Thanks to anyone who reads my thread and helps me!!!

You don't say what your folder structure is. The statement
package org.cadenhead.ecommerceimplies that your classpath contains a folder
org/cadenhead/ecommerceand that the class files reside in the ecommerce folder.
"org" is relative, it is contained in one of the classpath folders.
I created a project in Eclipse 3.1 name org.cadenhead. Created a package ecommerce. I cut and pasted your code into two java files in the ecommerce package. The only change I made was to change
package org.cadenhead.ecommerceto
package ecommerceCode compiles without error. So I think either your classpath does not contain org.cadenhead.ecommerce or the Item class is not in org.cadenhead.ecommerce.
Good luck

Similar Messages

  • Hi, Im new to Apple MacBook PRO. I have saved about 50GB files plus applications and message advises that my start up disk is almost full! My MacBook pro has a 500GB hard drive so don't know why this message is coming up. Please help.

    Hi, Im new to Apple MacBook PRO. I have saved about 50GB files plus applications and message advises that my start up disk is almost full! My MacBook pro has a 500GB hard drive so don't know why this message is coming up. Please help.

    MacBook Pro
    https://discussions.apple.com/community/notebooks/macbook_pro 
    https://discussions.apple.com/community/mac_os/mac_os_x_v10.7_lion?view=discussi ons

  • TS2446 On my I Pad I am getting a message that says "Your Apple ID has been Disabled" nothing else. I have not tried to log in so I don't know why this is happening. How do I get it enabled?

    On my I Pad I am getting a message tha says "Your Apple ID has been disabled". Nothing else. I have not tried to log in so I don't know why this is happening. How do I get it enabled?

    Read the article you linked.
    If changing your password does not resolve, then contact itunes support

  • Contact groups. My contacts get removed from the groups, not from All Contacts. I don't know why this happens. Anyone know why?

    Sometimes the contacts in certain groups are removed and the group is empty.  They do not get deleted, and are still in All Contacts, just get removed from the group.  Then I have to start all over again and add contacts to the groups.  This seems to happen randomly and I don't know why it does.  My contacts are synced with my Yahoo contacts.  I don't know if thats why.  Does this happen to anyone else?

    Thank You, thank You ...so much......that feature made me crazy!  
    Ocean20 wrote:
    This can be turned off in settings/accessibility/zoom. Then on the next screen turn off

  • I've an iMac with OS X 10.4.11. Sudden email problem: every received email has, after the header, 1 - 2 pages of technical data (e.g., Dkim-Signature, Domainkey-Signature, etc.) I don't know why this now happening, and I don't know how to get rid of it.

    I have an iMac using OS X 10.4.11. Beginning several days ago, all incoming emails have, after the usual email header and before the message appears, one to two pages of technical data (e.g., Dkim-Signature, Domainkey-Signature, Content-Transfer-Encoding, etc.). This is similar and more complex that the info one receives when an undeliverable email bounces back. I don't know where this stuff comes from, or how it came, and I don't know how to get rid of it. Any ideas? I'm something of a newbie to computers (um, what's a Tag?).

    That just sounds like the mail headers. Most people don't know (or care) about them so they're usually hidden.
    Check Mail -> Preferences -> Viewing -> Show header detail
    I'm guessing it's set to 'All'. Switch it to 'Default' or None as you prefer.

  • I seem to have fixed my problem of randomly occuring errors in my filterwheel control. But I don't know why this should actually work.

    Hi there,
    I am using a thorlabs fw102B filterwheel. It's connected via USB (simulating COM port, that's what it says in MAX). The second device is a camera, also connected via USB. The application is running 24/7, at least that's what it's supposed to do. LabView version is 8.6.
    The LabView code I wrote for this, was never really finished, meaning I totally ignored error handling in the first program version.  That never bothered me, because the program ran for weeks and months without any problem. Whenever I had to reboot my system it was not LabViews fault, but I was changing something else.
    Recently I was running into problems with the filterwheel (after a system reboot). However, I don't understand the error in the first place: The filterwheel is supposed to change position every 15 minutes, in between the camera is taking exposures, then the data is written to an ASCII-file (only ~156 kB). At first the error occured just once: the filterwheel was set to the wrong position for about 15 minutes, which might happen, as it is not really could in counting. A few days later it was in that wrong positon for one hour, so it didn't respond to the "move" order four times in a row. Finally I didn't move at all anymore. The error message I was getting is "0xFFFFFFF unkown status code". In my opinion the communcation to the filterwheel got lost somehow. I don't know a better explantion. 
    But why should it recover after some time?
    The problem usually occured at night, when nobody is there to watch.
    I investigated the behaviour in a second setup (see attachment). There is only the filterwheel connected. Through randomly unplugging the USB or power cable I was able to reproduce 'session handle is not valid', 'unkown status code' and 'session handle lost'. The program enters the 'true case', the session is to be closed and resetted, then it shall be reinitialized. This actually works as soon as the cables are reconnected. But why?
    The close.vi still returns 'session handle is not valid', The reset.vi returns the same, but initialize.vi returns 'No Error' and the system works again.
    What am I not getting here?
    I read some threads here and somebody mentioned for another instrument/problem to use the 'reset' command twice. So I tried 'close-initialize', 'reset-reset-initialize', 'reset-initialize' but only 'close-reset-initialize' works (not surprising). Yet I still get the same errors (probe 1 and 2). Am I introducing more bugs without knowing than I fixed?
    I AM CONFUSED.
    Carsten
    Attachments:
    error_catch.png ‏273 KB

    Hello Ulrich,
    thank you for your answer. Concerning the dataflow I agree and it is what I usually do. Actually I follow the dataflow paradigm whenever there is no problem (the 'false case' in the screenshot):
    “FW102x Initialize.vi” -> “FW102x Get Position.vi” -> “FW102x Set Position.vi”.
    Whenever there is a mistake, this just doesn't work with these drivers. The sequence
    “FW102x Initialize.vi” -> “FW102x Get Position.vi”  -> ///error/// -> “FW102x Close.vi”, “FW102x Reset.vi”  ;; “FW102x Initialize.vi”
    will give me errors for “FW102x Close.vi”, “FW102x Reset.vi”  and “FW102x Initialize.vi” reporting "session handle not valid". However, if I "bypass" the instrument handles directly from the first "Initialize" to "Close" and "Reset", they will report the same error, but the second "Initialize" will work again. I can even merge the first two frames and execute "Close" and "Reset" at the same time to do so. But whenever I try something else, e.g. do the 'correct' wiring, I am unable to close, reset or reinitialize. I have to restart LabView completely, to make the vi work again. So I guess the session is still hanging around somewhere in memory, but I can't access it anymore.
    Surprisingly, wherever I put Probes on the data handle wires they show the correct "ASRL5::INSTR" (with or without correct wiring). But only the "Bypass" wire makes the vi work. Since you couldn't find the drivers in the driver network, I guess they might just run into problems, if an error occurs.
    But thanks for your comment anyway. The problem is fixed for the moment. It's just that I prefer to actually know what I am doing here instead of producing some code I'd rather not show anyone.
    Carsten

  • I don't know why my iCal won't accept my Google password for syncing purposes.  I just updated the password last night. It says this: "The password may have entered is incorrect"

    My ICal, keeps saying: "The password may have been entered incorrectly. Reenter the password for account “Google” on the CalDAV server “calendar.google.com.”

    Greetings Joe,
    What version of the Mac OS are you running (Apple > About this Mac)?
    Try:
    Go to iCal > Preferences > Accounts and remove all unneeded accounts especially Gmail / Google.
    Go to iCal > Quit iCal
    Go to Macintosh HD > Applications > Utilities > Keychain Access
    Use the search bar to locate anything called "calendar.google.com" and then delete it.
    Go to Keychain Access > Keychain FirstAid > Repair
    Once complete go to Keychain Access > Quit Keychain Access
    Restart the computer.
    Go to iCal > Preferences > Accounts and re-enter your Google account.
    Hope that helps!

  • Please Help! I don't know why this is happening!

    I am playing a game through flash player projector. And one time i was playing and it closed and got deleted. I installed it many times and still the same thing happened. I cleared the data, checked for malware, and closed all programs. None of these worked. Can u help? Thanks

    It's extremely unlikely that we'll delete files off your filesystem.  Have you looked in the quarantine section of your virus scanner to see if it's getting flagged?

  • Why doesn't my number show up in iTunes or on my iPhone 5S (everything is up to date and I don't know why this is happening)?

    I've had to change SIM cards with my provider to have working 3G/4G. It works but the odd thing is when I plug my iPhone and I'm on iTunes. I don't see my number showing up. I see n/a each time. I know I have a number but it's not showing up I can make calls and text but it doesn't show my number. In my contacts section I don't see my number either. Why is this?

    You have a hardware issue.  Try a different USB port.  If that doesn't work, try a different docking/charging cable.  If that fails, check the USB properties in Device manager.  The ports MUST be USB 2.0.
    Also, try using a different computer....

  • Ping authorization via e-mail doesn't work. I have an iTunes account but must seek authorization for Ping. I don't know why this is but I never get an e-mail message with the link. Why?

    Hi. I use iTunes for podcasts and to burn MP3s from audible.com. It works great except PING. I need to confirm my identity to the PING server. It purports to sen me an e-mail but I never get it. Why is this?

    Hello Ulrich,
    thank you for your answer. Concerning the dataflow I agree and it is what I usually do. Actually I follow the dataflow paradigm whenever there is no problem (the 'false case' in the screenshot):
    “FW102x Initialize.vi” -> “FW102x Get Position.vi” -> “FW102x Set Position.vi”.
    Whenever there is a mistake, this just doesn't work with these drivers. The sequence
    “FW102x Initialize.vi” -> “FW102x Get Position.vi”  -> ///error/// -> “FW102x Close.vi”, “FW102x Reset.vi”  ;; “FW102x Initialize.vi”
    will give me errors for “FW102x Close.vi”, “FW102x Reset.vi”  and “FW102x Initialize.vi” reporting "session handle not valid". However, if I "bypass" the instrument handles directly from the first "Initialize" to "Close" and "Reset", they will report the same error, but the second "Initialize" will work again. I can even merge the first two frames and execute "Close" and "Reset" at the same time to do so. But whenever I try something else, e.g. do the 'correct' wiring, I am unable to close, reset or reinitialize. I have to restart LabView completely, to make the vi work again. So I guess the session is still hanging around somewhere in memory, but I can't access it anymore.
    Surprisingly, wherever I put Probes on the data handle wires they show the correct "ASRL5::INSTR" (with or without correct wiring). But only the "Bypass" wire makes the vi work. Since you couldn't find the drivers in the driver network, I guess they might just run into problems, if an error occurs.
    But thanks for your comment anyway. The problem is fixed for the moment. It's just that I prefer to actually know what I am doing here instead of producing some code I'd rather not show anyone.
    Carsten

  • I Don't Know Why This Happens To My New G580 Laptop

     This is what happens to my screen every so often.
    The day I got it new, it happened while I was trying to set it up. Does anyone have any ideas how to fix this?
    Link to pic
    Mod edit:  Changed pic to link per Forum rule:  50k limit for pics

    Hi Layekh,
    Thanks for posting and welcome to the communtiy. After reading this thread I will have to agree with madwolf1980. It does appear to more of a hardware problem rather than software. If you are confortable with opening the machine you may want to consider what was suggested bu madwolf1980. If you are not confortable with opening up your machine you may want to consider contacting our service team and let them check it out.
    Do let me know how it goes.
    regards 

  • I deleted all of the symantec software  on my macbook, but I am getting an error message saying to run live update or reinstall. I don't know why this is happening, I heard I may still have a file but I have looked and cannot find one. How do I fix this?

    If there is a leftover file, where do I find it. And is my computer at risk?

    I tried doing both, I couldnt find either symantec or live update in applications or when I searched through finder. I went to the activity monitor and found symantec and quit the process but the next time i logged on to my computer, it came back. this is what the error message looks like
    Thanks for trying!

  • I have purchased iphone 5 in 22/03/2013 but i was face a problem that on the both side from where we handle the phone from that end the body color is getting of i don't know why this is happen please suggest what should i do now

    i see that after 3 month from the purchase of my iphone 5 the body color from where we handle the phone while talking in getting color out from that side. please suggest me what should i do

    hello abhishek,
    if the issue was from beginning (dead on arrival) you can call the apple hotline and they can create a replacment for you.
    but if the issue wasnt from beginning than it is a cosmetical issue, cosmetical issues are not covered by the apple warranty. than you should make an appointment in an apple retail store and hope that the workers there replace that device.

  • Whenever I try to log into my itunes it says I have a -50 error, but I'm not downloading anything. I don't know why it won't let me log in.

    I don't know why my itunes won't let me log in. All the Apple website tells me is that it's an error when I'm downloading something, but I'm not downloading anything.

    Hey shelbylynn18,
    Thanks for the question. (-50) is a timeout error that can occur when downloading content or when simply trying to access the iTunes Store. If you have automatic downloads enabled, you may be experiencing this error when iTunes is attempting to automatically download available content.
    iTunes Store: "Error (-50)" when downloading purchased content
    http://support.apple.com/kb/TS1583
    This can happen when the connection timeout occurs while downloading purchased content from the iTunes Store. Certain types of software may also affect the way a computer sends and receives information from the internet. Here are a few examples of these types of software:
    - Firewalls
    - Web Accelerators
    - Ad Filters
    - Virus Protection Software
    Resolution
    If you have any of the software listed above, and you cannot access the iTunes Store or complete your download, you will need to configure these applications to allow iTunes to connect to the Internet.
    Refer to the documentation that came with that software, and if necessary contact the software's manufacturer. You will need to configure the software to allow the following domains to send and receive data from the Internet.
    - itunes.apple.com
    - ax.itunes.apple.com
    - albert.apple.com
    - gs.apple.com
    - deimos3.apple.com
    - phobos.apple.com
    If a web accelerator appears to be causing the issue, contact your Internet Service Provider (ISP) or the software manufacturer. If your computer is on a network, you may also want to try using a different computer on the network, or discuss the issue with the network administrator.
    Additional Information:
    iTunes: Advanced iTunes Store troubleshooting
    http://support.apple.com/kb/TS3297
    Thanks,
    Matt M.

  • HT4044 My Ipad2 screen has a greenish hue. Almost looks like Sepia. Don't know why or how to fix it. help!

    How can I fix my Ipad2 from looking greenish/sepia? Don't know why this happened all of a sudden and want to know how to fix it. does anyone know?

    As a first step, try doing a Reset PRAM.
    http://support.apple.com/kb/ht1379
    The sound settings are stored in PRAM.  If there is some corruption of settings in PRAM, a reset may fix your problem.

Maybe you are looking for

  • How do I move a clip with transitions attached on the primary storyline?

    One more frustrating problem with the mysterious magnetic timeline: on the priumary storyline I created a text clip with a gap clip on each side, then added cross dissolve at the beginning and end of the clip so that it fades in and out to black: Now

  • BT Openzone problem in London

    Hi, I live in London, UK, and have a BT Total Broadband connection, which I just realised came with inclusive BT Openzone minutes. I rand BT Openzone and they immediately set up an account for me with username and password, and told me to go to a hot

  • Slide Show on Home Page Creates Scroll bar in browser...

    I have created my site, and at the tope of it I have a hero Slider Composition with text in it. But, when I view it in the browser, it scrolls to the right. But, if I delete the composition slide show, the scroll bar disappears. I've tried to re-crea

  • Cannot open PDFs in Mail with Mavericks

    When I get emails containing PDFs in Mavericks, I can see the PDF in the context of the message, but there is no indication that there are any attachments, no way to save them to a location, and I cannot even click on them in the message to get them

  • Taking data from two different server in a single table

    Hi All, can u plz tell me i want take a data from a two different server in a single table Thanks, Bell.