File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Development

 
swaraj gupta
Ranch Hand
Posts: 182
C++ Java Oracle
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Source: KS && BB book:
When searching for class files, the java and javac commands don't search the current directory by default. You must tell them to search there. The way to tell java or javac to search in the current directory is to add a dot (.) to the classpath:

-classpath /com/foo/acct:/com/foo:.

........the dot (.) at the end of the declaration instructs java or javac to also search for class files in the current directory. (Remember, we're talking about class files—when you're telling javac which .java file to compile, javac looks in the current directory by default.)

The two BOLD letter parts of the above quote confusing me a bit, will anybody please clarify the situation here.


These are conclusions I have drawn. Please correct if I am wrong at any of these point:
1> javac searches the current directory for .java file by default.
2> javac DOES NOT search the current directory for supporting .class files needed for the compilation .java file by default.
3> java never searches the current directory by default.
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
swaraj gupta wrote:
1> javac searches the current directory for .java file by default.


javac doesn't use the classpath to find the .java file. It uses the location that you specify in the command line.

swaraj gupta wrote:
2> javac DOES NOT search the current directory for supporting .class files needed for the compilation .java file by default.


If you don't set the classpath (either environment or command line) then javac uses the current directory as the classpath.

swaraj gupta wrote:
3> java never searches the current directory by default.


If you don't set the classpath (either environment or command line) then the JVM uses the current directory as the classpath.


Henry
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic