aspose file tools*
The moose likes Java in General and the fly likes What's wrong with this code?? please help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "What Watch "What New topic
Author

What's wrong with this code?? please help

Anil Jain
Ranch Hand

Joined: Mar 10, 2002
Posts: 51
Hello friends!!
I am trying to compile these codes which belong to same package. The first code compiles allright but the second one gives me errors. Both of them belong to same package.
**********Item.java file****************

I get the folloing errors when i compile the ShoppingCart.java
C:\Tomcat\jakarta\webapps\myJSPApp\WEB-INF\classes\ShoppingCart.java:5: cannot resolve symbol
symbol : class Item
location: class jspin24hrs.hour16.ShoppingCart
public void addItem(Item i){items.addElement(i);}
^
C:\Tomcat\jakarta\webapps\myJSPApp\WEB-INF\classes\ShoppingCart.java:9: cannot resolve symbol
symbol : class Item
location: class jspin24hrs.hour16.ShoppingCart
Item item = (Item)itemEnum.nextElement();
^
C:\Tomcat\jakarta\webapps\myJSPApp\WEB-INF\classes\ShoppingCart.java:9: cannot resolve symbol
symbol : class Item
location: class jspin24hrs.hour16.ShoppingCart
Item item = (Item)itemEnum.nextElement();
^
C:\Tomcat\jakarta\webapps\myJSPApp\WEB-INF\classes\ShoppingCart.java:20: cannot resolve symbol
symbol : class Item
location: class jspin24hrs.hour16.ShoppingCart
Item item = (Item)itemEnum.nextElement();
^
C:\Tomcat\jakarta\webapps\myJSPApp\WEB-INF\classes\ShoppingCart.java:20: cannot resolve symbol
symbol : class Item
location: class jspin24hrs.hour16.ShoppingCart
Item item = (Item)itemEnum.nextElement();
^
5 errors
Tool completed with exit code 1

PLEASE LET ME KNOW WHERE I AM MAKING THE MISTAKE
THANKS,
(edited by Cindy to format code)
[ August 13, 2002: Message edited by: Cindy Glass ]

Anil Jain<br />Sun Certified Java(2) Programmer
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Look in directory /jspin24hrs/hour16 and see if the Item.class file really IS THERE.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Kevin Li
Greenhorn

Joined: Sep 25, 2001
Posts: 21
You could try again as followed:
1.set classpath=.;%classpath%
2.come in directory "C:\Tomcat\jakarta\webapps\myJSPApp\WEB-INF\classes\"
3.execute compile command,
java -d . *.java
Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
My guess is it's the class path. Notice a few things. One is both classes are in a package, but from your error code, it looks as though you did NOT putthem in that package folder structure. So you need to do this:
1. put the files in:
${curr_folder}/jspin24hrs/hour16/Item.java
${curr_folder}/jspin24hrs/hour16/ShoppingCart.java
2. Stay in the current Folder and do:
javac -classpath . jspin24hrs/hour16/ShoppingCart.java
Since it uses Item.java, that will compile both files (do not copy the recently compiled Item.class file into the folder).
Biju Philip
Greenhorn

Joined: Nov 03, 2001
Posts: 7
As another suggestion (though it does not directly relate to your issue), try using the Jikes compiler. The error messages are a bit more clear.
 
jQuery in Action, 2nd edition
 
subject: What's wrong with this code?? please help