jQuery in Action, 3rd edition
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
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 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
I agree. Here's the link: http://aspose.com/file-tools
subject: Classpath+packages
It's not a secret anymore!