I'm trying to run a simple example using my own built Jar file which requires the spring framework Jar on the classpath. I am doing this with JSE 6, Spring Framework 2.5.1 and cygwin 1.7.5.
When I attempt to do this I get the following error message;
So in order to isolate the problem I created a simple example where I create two separate Jars with the second depending on the first;
Both are compiled and packaged into their own Jar files, DependOn.jar and Dependent.jar. Clearly Dependent needs to be built with DependOnMe on the classpath. Dependent.jar has a Main-Class in the manifest, com.mcparland.john.dependent.Dependent.
Then I run as follows and get the same error;
I cannot see the problem but I imagine it might have something to do with the use of -cp. I do not have a CLASSPATH set.
In the small sample above both package hierarchies exist in /home/John/testJarDependencies/<projectName>/bin where project names are dependOn and dependent.
unfortunately I tried that but with no luck. It's a bit confusing since I believe the java command is looking for windows paths but I'm doing this in a cygwin environment.
I tried the following;
And each time received the same errors. The reason for each different type is;
1. /cydrive/... is the absolute path as per cygwin's view of the file system
2. /Spring/... is the absolute path when looking at it from a Windows point of view (well using different separators and ommitting the C). This is the format used in the Ant build file I used.
The -cp flag is ignored when using -jar. Instead you must add the Spring JAR file in the Class-Path entry of your manifest file. And no, that does not like absolute paths much, I can already tell you that.
Sorry I'm not sure I understand why I need to put the class path in the Jar. The main reason why is that if I do not package HelloApp into a Jar file and instead run it from the directory containing the class hierarchy I still get the same error;
What happens if you use : as the separator? Although you're using Cygwin, I think that the java executable is a Windows one. The class path is not split by the shell but by the JVM, and a Windows JVM will try to split at ;.