Why wont this jar execute (one way fine, the other is not)

Without using a executable jar this works fine:

java.exe -classpath myproject\classes;lib1.jar;lib2.jar;lib3.jar MyMainClass

MyMainClass is my target class stored in myproject\classes

I make an executable jar called Project.jar (basically all content in myproject\classes with usual manifest file containing target class) and then try

java.exe -classpath lib1.jar;lib2.jar;lib3.jar -jar Project.jar

This does not work and gives error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/beans/factory/InitializingBean

The class org/springframework/beans/factory/InitializingBean is contained in lib1.jar

I must be missing something fundamental about creating executable jars? Any ideas or pointers?

[781 byte] By [driving_me_nutsa] at [2007-11-26 14:48:46]
# 1

I've simplified my problem so someone could help me please!!!!

The following runs fine:

java -cp .;Model.jar Test

The following fails:

java -cp .;Model.jar -jar Test.jar

Exception in thread "main" java.lang.NoClassDefFoundError: Model at Test.main(Test.java:8)

Model.jar contains one class model.Model.class

Test.jar contains one class Test.class plus manifest file. The Test class simple does the following:

import model.Model;

public class Test

{

public static void main(String[] args)

{

System.out.println("Start");

Model model = new Model();

System.out.println("End");

}

}

Any ideas why?

driving_me_nutsa at 2007-7-8 8:36:37 > top of Java-index,Desktop,Deploying...
# 2

Found answer on another web site. It seems daft to me but there you go

An executable JAR must reference all the other dependent JARs it requires through the Class-Path header of the manifest file. The environment variable CLASSPATH and any class path specified on the command line is ignored by the JVM if the -jar option is used.

driving_me_nutsa at 2007-7-8 8:36:37 > top of Java-index,Desktop,Deploying...