Reputation: 177
I want to make a simple ant build hibernate test project. There is no error during the compilation and the build (jar).
But when I run it I get this:
java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration ...
I have found an advise, what said : jars should be added to classpath in the command line, (classpath is ignored when the jar run from ant ... ehh), ok I tried the following:
java -jar dist/student.jar -cp /home/myname/workspace/basic_ant1/lib/hibernate/hibernate-core-4.2.8.Final.jar
But still have the some error :NoClassDefFoundError ...
What did I wrong ?
Thanks for the replies in advance.
(org.hibernate.cfg is in hibernate-core-4.2.8.Final.jar)
Cs.
Upvotes: 0
Views: 109
Reputation: 122364
-jar
and -cp
are mutually exclusive.
If you want to use java -jar
then your main JAR file needs a Class-Path
entry in its manifest that points to all the other jars its Main-Class
requires (the manifestclasspath
task is a handy way to generate this value).
If you use java -cp
then you have to give the main class name on the command line, the Main-Class
from the manifest is ignored.
Upvotes: 1