File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Classpath+packages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Classpath+packages" Watch "Classpath+packages" New topic


Lucky J Verma
Ranch Hand

Joined: Apr 11, 2007
Posts: 278
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

Joined: Apr 11, 2007
Posts: 278
one more doubt ,
we have two files importing Test1.class in it.
I read ,whenever we compile ,it compiles automatically.
but we can use an alernative option by not mentioning classpath option on command line.
javac classpath="." //compiles in same dir-structure.

but how about alternative,
javac classpath="" //gives an error,wont find Test1.class
I agree. Here's the link:
subject: Classpath+packages