• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

classpath problem

 
Layla Rashid
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am trying to run this Category.java file


my Store.java file is


when I try to compile I get this error.

C:\Program Files (x86)\Java\jdk1.5.0_20\bin>javac -cp C:\Users\silvi\workspace\s
hop\src\ca\acadiau\ecomm C:\Users\silvi\workspace\shop\src\ca\acadiau\ecomm\Cate
gory.java
C:\Users\silvi\workspace\shop\src\ca\acadiau\ecomm\Category.java:6: cannot find
symbol
symbol : class Store
location: class ca.acadiau.ecomm.Category
public Category (Store s, int n){
^
1 error


Please let me know how to solve this.

Thanks
Layla


 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Layla. First compile Store.java and then compile Category.java.
 
Layla Rashid
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I already did that .
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I already did that .


So you still get error ?

you dont need to compile Store.java separately..it automatically compiles when you compile Category.java. use -classpath properly to get compiled.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouldn't it be easier to put the Java compiler on your path and work in your actual directory?!
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15354
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

C:\Program Files (x86)\Java\jdk1.5.0_20\bin>javac -cp C:\Users\silvi\workspace\shop\src\ca\acadiau\ecomm C:\Users\silvi\workspace\shop\src\ca\acadiau\ecomm\Category.java
C:\Users\silvi\workspace\shop\src\ca\acadiau\ecomm\Category.java:6: cannot find symbol
symbol : class Store
location: class ca.acadiau.ecomm.Category
public Category (Store s, int n){
^
1 error

Multiple things are going wrong here...

Do not run this from the JDK bin directory. A command like this would write the resulting class files in your JDK bin directory, and that's not what you want. Follow step 4 of the JDK installation instructions to put the JDK bin directory in your PATH, so that you can call it from anywhere.

You have to set the classpath to the base directory of the package structure. So, don't set it to C:\Users\silvi\workspace\shop\src\ca\acadiau\ecomm, but to C:\Users\silvi\workspace\shop\src. If you compile with that directory as the current directory, you don't have to set the classpath at all.

After setting the PATH, do something like this:

C:
cd \Users\silvi\workspace\shop\src
javac ca\acadiau\ecomm\Category.java

You will now have a Category.class file in the same directory of your source file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic