File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error can't find class

 
Di Fusio
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi peeps,

I've got the following two classes:


and:


Item.java compiles just fine, but Storefront.java gives me:

C:\JavaWork\org\cadenhead\ecommerce>javac Storefront.java
Storefront.java:15: cannot find symbol
symbol : class Item
location: class org.cadenhead.ecommerce.Storefront
public Item getItem(int i) {
^
Storefront.java:11: cannot find symbol
symbol : class Item
location: class org.cadenhead.ecommerce.Storefront
Item it = new Item(id, name, price, quant);
^
Storefront.java:11: cannot find symbol
symbol : class Item
location: class org.cadenhead.ecommerce.Storefront
Item it = new Item(id, name, price, quant);
^
Storefront.java:16: cannot find symbol
symbol : class Item
location: class org.cadenhead.ecommerce.Storefront
return (Item)catalog.get(i);
^
Note: Storefront.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors


I can't find the reason for this error.

Any help would be great.

 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12015
24
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a classpath set?
 
Di Fusio
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah:

.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip;C:\Program Files\Java\jdk1.6.0_24\Programs\

Should i add c:\javawork?
 
Rob Spoor
Sheriff
Pie
Posts: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add, no. Replace the current value, yes. But not system wide; simply use the -cp flag.
 
Hauke Ingmar Schmidt
Rancher
Posts: 436
2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Di Fusio wrote:


Item.java compiles just fine, but Storefront.java gives me:

[i]C:\JavaWork\org\cadenhead\ecommerce>javac Storefront.java


You are in the wrong directory when calling javac. Compile from c:\JavaWork as current directory.
 
Di Fusio
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great, this works guys, but now it gives me:

C:\JavaWork\org\cadenhead\ecommerce>javac Storefront.java
Note: Storefront.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

C:\JavaWork\org\cadenhead\ecommerce>javac -Xlint:unchecked Storefront.java
Storefront.java:12: warning: [unchecked] unchecked call to add(E) as a member of
the raw type java.util.LinkedList
catalog.add(it);
^
Storefront.java:24: warning: [unchecked] unchecked conversion
found : java.util.LinkedList
required: java.util.List<T>
Collections.sort(catalog);
^
Storefront.java:24: warning: [unchecked] unchecked method invocation: <T>sort(ja
va.util.List<T>) in java.util.Collections is applied to (java.util.LinkedList)
Collections.sort(catalog);
^
3 warnings

Is that classpath related as well?
 
Hauke Ingmar Schmidt
Rancher
Posts: 436
2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, that is because your code is using collections without generic types - which you should add.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic