• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Compiler

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Consider these two classes, ClassA and ClassB. ClassA has a reference to ClassB.




According to a book I am reading when I compile ClassA.java with javac ClassA.java, the Java compiler will compile ClassB.java as well automatically because ClassA has a reference to it.
I have tried this and it doesn't seem to be the case.

Can anyone confirm this ?

Cheers
Finner
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jones,
I try to detail the above code below and let me know if at any chance it clarified.



Then under the same package have class A:



Now when u try to compile the class A and run it it did print the statement in the default constructor: In the constructor ClassB()

Since the classes marked public can be accesed from anywhere!!

If you try introduce a compile time error in class B and run class A it throws exception.
So im not sure what exactly ur looking in this question.

Thanks
Balaji.S
 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think what Finner is asking is that the ClassB.class is not created although ClassA has reference to it.
Can somebody please put some light into this concept
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure it works:
 
Finner Jones
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Barry Gaunt:
Sure it works:





it does work !!!
I had the above classes in a package and was issuing the javac from the wrong folder. D'oh!
Thanks guys !
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic