wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes javac 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 "javac "an incomplete discussion"" Watch "javac "an incomplete discussion"" New topic
Author

javac "an incomplete discussion"

Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
I lost the thread where this discussion was going on, but meanwhile left
without any final conclusion.

javac finds the needed source file and complies them as well with the main
source file.

I disagreed with that.

"javac -cp only finds class files. If the needed class file does not exist,
it gives compiler error."

What I know:
"Suppose Source A.java is using B's (public class) instance and methods so when you complile A.java, B.class must be present in order to compile A.java."

Is that right? Yes(OK)/No(Why?)

Thanks,
cmbhatt


cmbhatt
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Follow through this:

Where did B.class come from?


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Sorry Barry but I couldn't completely understand the code
provided by you!





Please elaborate!

Waiting...
cmbhatt
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
Which step is giving you difficulties? Were you able to do them all yourself?


Ping & DNS - my free Android networking tools app
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Alright Barry! I got exactly what you did there!

My question is if B.class does not exist in the "two" directory,
and we try to compile A.java that is in the "one" directory,
would it also compile B.java that is in the "two" directory.
I know it is senseless question.


We must compile B.java before we can compile A.java, because
javac will search for B.class and not B.java.


We can do it in one line two like:

top>javac one/A.java two/B.java

italics is my doubt and bold is what it should be!

Guide me!!

Thanks,
cmbhatt
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
would it also compile B.java that is in the "two" directory?


Well, that's what it did! I certainly did not compile it.
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Great Barry,

I did the same, and it worked. B.class automatically created in
"two" directory.

But if we give classpath (-cp) with javac, then what happens.


Thanks,
cmbhatt
 
Consider Paul's rocket mass heater.
 
subject: javac "an incomplete discussion"
 
Similar Threads
Classpath setting involving java and javac
classpath
Why javac does not find this Java file?
Import
Compiling with jar files.