1

I have a java file to be exected in LInux server . I am writing a script for this . My question is inside the Script do i need to mention name of each jar as shown below CLASSPATH=./lib/log4j-1.2.8.jar:./lib/mail.jar:./lib/javax.servlet.jar:./lib/ojdbc.jar:./lib/activation.jar:./lib/commons-logging.jar:.

or can i mention as *.jar directly as shown

CLASSPATH=./lib/*.jar

Please share your inputs . Thanks

  • I think you cannot use wildcards. So it's the first way. Nevertheless if that's a maven project, there's maven-lib plugin which generates a classpath var inside the manifest and includes all dependencies which are required. This way you don't need to manage this yourself. – hovanessyan Feb 17 '12 at 09:50
  • Thanks but this is not a Maven Project –  Feb 17 '12 at 09:51
  • also check this out http://stackoverflow.com/q/219585/1007273 – hovanessyan Feb 17 '12 at 09:53

1 Answers1

1

Here's a simple script:

CLASSPATH=
for f in ./lib/*; do CLASSPATH=$f:$CLASSPATH;done;
CLASSPATH=$CLASSPATH.

It can be expanded to look better:

CLASSPATH=
for f in ./lib/*
do
    CLASSPATH=$f:$CLASSPATH
done
CLASSPATH=$CLASSPATH.
core1024
  • 1,902
  • 15
  • 22