This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
This is not a java language problem per se, but I couldn't spot a packaging forum..
I'm playing with hibernate and have built a simple utility packagewhich I was intending to use to replace an old broken perl script on a unix host.
I've rolled the package up into a simple jar file to try to keep it clean, and what I'd like to do is to run it via a simple shell script so that I can pipe away the output and do other things with it.
However what I get when I invoke the shell script is an exception relating to one of the imported libraries: java.lang.NoClassDefFoundError: org/hibernate/Session
How about prepending your classpath argument with .:
thus, your classpath definition should look like this:
[ April 05, 2006: Message edited by: Eduardo Dela Rosa ] [ April 05, 2006: Message edited by: Eduardo Dela Rosa ]
Joined: Apr 05, 2006
Just tried that one and it makes no difference I'm afraid, and I'm not sure I'd expect it to - the org.hibernate.Session class should be found in /usr/local/classes/hibernate/hibernate3.jar, at least, that's what I'm expecting!
When you use the -jar option when running java on the command line, the -classpath option is completely ignored. So all that typing you did was for naught. If you want those jars to be in the classpath, you have to put them in the manifest of your executable jar file (as Class-Path: entries I believe).
Or alternatively don't use the -jar option, and just make your executable jar file one of the many in the classpath.
Eduardo Dela Rosa
Joined: Apr 15, 2004
Yes, Paul is right, because the manifest file (MANIFEST.MF) is the file where you declare information about the files packaged in your JAR file.