Is the current path `.` in the classpath by default?

From Oracle's page on setting 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.

Use ; for Windows and : for Unix-like operating systems as a separator for multiple paths.


If you add classpath then current path is omitted, which is a very very unpleasant and unexpected behavior :(

Moreover to add current path I found (at least for ubuntu) that IT IS NOT ENOUGH to add . in classpath but you have to add ./*

For example (this will not work)

java -ea -cp ".:lib/*" org.testng.TestNG suites/regression.xml

will NOT work if you have a jar file in current path

the correct one is

java -ea -cp "./*:lib/*" org.testng.TestNG suites/regression.xml

I hope no one shoots himself or have a heart attack!

Tags:

Java

Ubuntu