Reputation: 339
I have such bash script start.sh:
export JAVA_HOME=/home/qds/bin/jdk1.6.0_22
export QDS_HOME=/home/qds
$JAVA_HOME/bin/java -classpath $QDS_HOME/lib/*:$QDS_HOME/lib/commons/* com.qds.Main $@
In the directory /home/qds/lib I have necessary libraries and my jar file, wich contains:
com\qds\config
com\qds\entities
com\qds\hibernate
com\qds\protocols
com\qds\util
com\qds\Main.class
but when I run ./start.sh, I have:
./start.sh Exception in thread "main" java.lang.NoClassDefFoundError: com/qds/Main (wrong name: Main) at java.lang.ClassLoader.defineClass1(Native Method)
Upvotes: 0
Views: 562
Reputation: 115328
Java does not support wildcards in option -classpath. Try to remove * from $QDS_HOME/lib/* and from $QDS_HOME/lib/commons/*
BTW this is relevant for windows too.
Classpath should contain 1. directories 2. explicitly written jar files.
If you have many jar files you can create script that composes the command line option. For example on linux
-classpath `ls -1|tr '\n' :`
composes classpath delimited with colon
Upvotes: 1
Reputation: 39750
You have to specify what your main class is going to be in one of several ways
Upvotes: 1