As far as I've been able to discern. The "cannot find symbol" compile error is a result of one of 2 mistakes.

1) The class name is spelled incorrectly
2) The class isn't in the same directory as the class trying to instantiate the object or the class isn't in the CLASSPATH variable.

I have a class called Item(already compiled in it's .class file), and it's in the same directory as Storefront.java. Storefront.java instantiates a new Item object, yet when I try to compile Storefront I get a "cannot find symbol error". Here's my bash commands to help illustrate the problem.

dan@dan-laptop:~/java/com/stonehambey/ecommerce$ ls
Item.class  Item.java  Storefront.java
dan@dan-laptop:~/java/com/stonehambey/ecommerce$ javac Storefront.java
Storefront.java:11: cannot find symbol
symbol  : class Item
location: class com.stonehambey.ecommerce.Storefront
		Item it = new Item(id, name, price, quant);
		^
Storefront.java:11: cannot find symbol
symbol  : class Item
location: class com.stonehambey.ecommerce.Storefront
		Item it = new Item(id, name, price, quant);
		              ^
2 errors
dan@dan-laptop:~/java/com/stonehambey/ecommerce$

Obviously I'm missing something about how packages and classpaths work, but I don't know what. Any help would be much appreciated. :)

Re: common problem, but still can't solve... 80 80

Do you have "package" declaration of your Item class?

Re: common problem, but still can't solve... 80 80

The Item class is in package com.stonehambey.ecommerce

Re: common problem, but still can't solve... 80 80

Not the location of the file, but does the class Item starts with

package com.stonehambey.ecommerce

???

Re: common problem, but still can't solve... 80 80

Sorry, yes it does :)

Re: common problem, but still can't solve... 80 80

Ohh, little slower today.
In your class Item, did you declare constructor that will initialize this class variable with 4 provided values? Something like this?

public Item(int id, String name, double price, int quant){
    itemID = id;
    itemName = name;
    itemPrice = price;
    itemQuant = quant;
}
Re: common problem, but still can't solve... 80 80

I've pasted the file, it might be easier :)

http://paste.ubuntu.com/94519/

Re: common problem, but still can't solve... 80 80

I see nothing wrong with it. Do you mind to post Storefront.java?

Re: common problem, but still can't solve... 80 80

sure

http://paste.ubuntu.com/94527/

Although here is something interesting. While I've been posting I've been messing with the files in eclipse. Now eclipse builds as I go and when I navigated to the directory I see a Storefront.class sitting there. Eclipse must've managed to build it somehow. However the JDK javac is still reporting the same error. Strange (although I'm pretty new to Java so maybe I'm missing something...)

Re: common problem, but still can't solve... 80 80

That explain a lot. If you use command line to compile it you need to do it as follows

javac com/stonehambey/ecommerce/Storefront.java

where both files have to be in respectable locations and you need to run javac from the directory that is parent to your "com" so in your case judging by pasted console output in java directory

dan@dan-laptop:~/java$ javac /com/stonehambey/ecommerce/Storefront.java
Re: common problem, but still can't solve... 80 80

Ah, so that's what I was doing wrong. My thanks to you, sir :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.