JavaUser
JavaUser

Reputation: 26384

java class files in current directory?

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.

Upvotes: 5

Views: 10979

Answers (1)

Jigar Joshi
Jigar Joshi

Reputation: 240996

It checks the current directory first. If the class is not found, it searches for that class in the class path.

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, you must include "." in the new settings. [source]

Upvotes: 10

Related Questions