• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What's wrong with this code?? please help

 
Anil Jain
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look in directory /jspin24hrs/hour16 and see if the Item.class file really IS THERE.
 
Kevin Li
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic