What is the meaning of “.:./*” in classpath?

Viewed 69

I have the below script to run MyDBCreateSchema/MyDBCreateSchema.class to initialize a database.

java –cp ".:./*" MyDBCreateSchema dbHost 1433 id password DBName

What is ".:./*"?

1 Answers

Well, the first "." before ":" means the current directory, so all .class files in the current directory are included. The "./*" after the ":" I don't think means anything, as I don't think Java can expand the '*' character. If it does, this probably means all the sub-directories immediately under the current directory will also be included in the classpath (i.e. all .class files in these subdirectories will, supposedly, be included in the classpath).

Either way, this is very unreadable, it makes more sense to create a variable in a bash script and append the individual directories either manually or with something like:

CLASSPATH="."
for DIRECTORY in $(ls /some/directory); do
    CLASSPATH+="${CLASSPATH:+:}$DIRECTORY"
done

java -cp "$CLASSPATH" ...

You get the drift...

Related