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?

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"
| improve this answer | |
  • the files are not jars, but resource files like .properties and log4j.properties. – Blankman Mar 11 '13 at 0:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.