0

I am doing this in a script:

if [ -d $SERVICE_HOME/../config ]; then
  CLASSPATH="$SERVICE_HOME/../config:$CLASSPATH"
fi

And the /config folder has sub-folders in it also, will files in the subfolder be added to the classpath?

1 Answer 1

0

The answer depends on the content of the folder.

class files in folder

The hierarchy below the folder is a one-to-one mapping to the package structure of your classes.

E.g. the file ./org/example/MyClass.class will be used for the class org.example.MyClass.

jar files in folder

These files will be ignored, because a jar file has to be explicitly added to the classpath.

E.g. CLASSPATH=${CLASSPATH}:${SERVICE_HOME}/mylib.jar

some notes

  • A classpath should normally only appended. With the addition of an element on the beginning you may incidentally overwrite another class.
  • In bash you may also use this shorter construct for appending:
    CLASSPATH+="$SERVICE_HOME/../config"
1
  • the files are not jars, but resource files like .properties and log4j.properties.
    – Blankman
    Mar 11, 2013 at 0:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .