wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes compling files using classpath  option Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "compling files using classpath  option" Watch "compling files using classpath  option" New topic
Author

compling files using classpath option

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

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 ?


OCPJP 6.0 93%
OCPJWCD 5.0 98%
Prithvi Sehgal
Ranch Hand

Joined: Oct 13, 2009
Posts: 774
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,


Prithvi,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup
Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 438

-cp option may not run on all the machines
so I recommend you to use the -classpath option

SCJP 6 [86%] June 30th, 2010
OCPWCD [84%] March 26th, 2013
If you find any post useful, click the "plus one" sign on the right
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compling files using classpath option
 
Similar Threads
Compiling problem for Scjp
java command question
CLasspath Problem
question about classpath
K&B Chapter 10 Self Help Question 9