This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes javac command and -cp . Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "javac command and -cp ." Watch "javac command and -cp ." New topic
Author

javac command and -cp .

Cyril Bil
Greenhorn

Joined: Oct 10, 2011
Posts: 9
Hi guys.
I have this code:



Is there a difference between :

javac my/path/to/java/Class1.java

and

javac -cp . my/path/to/java/Class1.java

Because I have the same result : compilation of the 2 classes

Thanks ;)


OCPJP
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3361
    
    9
Yes, in the first case the class path is determined by the CLASSPATH environmental variable, or if it's not set, then the current directory is used for the class path.

The second case explicitly sets the class path to the current directory, overriding the CLASSPATH variable if it is set.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javac command and -cp .
 
Similar Threads
multiple inheritance
Refering to another class's instance of a different class, inside a class
naming : package, inner classes
Confusion Question
Package & Compilation Problem