• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

javac "an incomplete discussion"

 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Follow through this:

Where did B.class come from?
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Barry but I couldn't completely understand the code
provided by you!





Please elaborate!

Waiting...
cmbhatt
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which step is giving you difficulties? Were you able to do them all yourself?
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic