• 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

Classpath+packages

 
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am little confused when using package hierarchy in java files and their compilation.
i just want to know what i have understood ,is it correct about javac.

When Javac compiles a .java file with some package statements,
-> .java file is put into same directory structure as package
->javac forms .class into same directory structure automatically like if we change destination directory
->javac searches for reference classes(if any ) by prefixing with directory-structure as package hierarchy.
 
Lucky J Verma
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
one more doubt ,
we have two files Test2.java importing Test1.class in it.
I read ,whenever we compile Test2.java ,it compiles Test1.java automatically.
but we can use an alernative option by not mentioning classpath option on command line.
javac classpath="." Test2.java //compiles Test1.java in same dir-structure.

but how about alternative,
javac classpath="" Test2.java //gives an error,wont find Test1.class
 
A magnificient life is loaded with tough challenges. En garde tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic