tags:

views:

29

answers:

1

How "java" knows the class file to execute without setting the class path.ie.,Does it check in the current directory by default or we need to set the class path for current directory too.

+3  A: 

It checks the current directory first.

If class not found then it search for that class in class path.

More sophisticatedly

The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path

from doc

org.life.java
is it correct .I read in some book like it wont check the current directory explicitly we need to set class path for current directory too...!~
JavaUser
It's up to the vendor that writes the JVM. The standard implementation from Sun/Oracle looks in the current working directory first. Some oddball runtime could do it differently.
erickson
edited the answer. check the doc
org.life.java