• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error can't find class

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have a classpath set?
 
Di Fusio
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add, no. Replace the current value, yes. But not system wide; simply use the -cp flag.
 
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, that is because your code is using collections without generic types - which you should add.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic