• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compling files using classpath option

 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
KB book Ch-Development SELF TEST


9. Given the following directory structure:
x-|
|- FindBaz.class
|
|- test-|
|- Baz.class
|
|- myApp-|
|- Baz.class


  And given the contents of the related .java files:

  In the test directory:
  In the myApp directory:

--------------------------------------------------------------------------
Baz.java complied fine and is store in the test directory.
i am trying to compile the file FindBaz.java using this command at cmd:

C:\PROGRA~1\Java\JDK16~1.0_1\bin\x>javac FindBaz.java

but i get the following error

FindBaz.java:2: cannot find symbol
symbol : class Baz
location: class FindBaz
public static void main(String[] args) { new Baz(); }
^
1 error



how to remove this error ?
-------------
then ,i cut the file from x to test directory where the Baz.java file is placed along with it's Baz.class file



C:\PROGRA~1\Java\JDK16~1.0_1\bin\x>cd test

C:\PROGRA~1\Java\JDK16~1.0_1\bin\x\test>javac FindBaz.java

FindBaz.java:2: cannot find symbol
symbol : class Baz
location: class FindBaz
public static void main(String[] args) { new Baz(); }
^
1 error



what shall i do ?
 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

As per my understanding, you need to specify the correct path for Baz class when you try to compile FindBaz.java
Even putting the class into same directory will not solve the problem. Provide the correct path till Baz using -cp flag.
It will solve your problem.

Hope this helps,
 
Prasad Kharkar
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
-cp option may not run on all the machines
so I recommend you to use the -classpath option
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic