Re: Problem with .jar file
Luis Angel Fdez. Fdez. wrote:
Then java -jar -cp .:derby.jar MyJar.jar doesn't work... It's not
able to load the jdbc driver.
Piotr Kobzda wrote:
"When you use this option, the JAR file is the source of all user
classes, and other user class path settings are ignored."
Quoted from:
<http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html#-jar>
Luis Angel Fdez. Fdez. wrote:
I tried, I don't know if it's right, to put derby.jar into MyJar.jar
and added: Class-Path: derby.jar to manifest file, but I get the same
error message.
What am I doing wrong?
Piotr Kobzda wrote:
Everything seems to be correct.
Except for where the other JAR was placed.
But you probably forgot to copy derby.jar into your jar's location.
In other words, put the other JAR not inside the application JAR but in the
same directory as the application JAR.
Again, read the tools documentation. RTFM is an amazingly useful approach.
<http://java.sun.com/javase/6/docs/technotes/guides/jar/index.html>
If you use it often, you may also copy derby.jar into
<JRE-HOME>/lib/ext/ directory, that way will no longer need to list it
as a class-path entry.
See also:
<http://mindprod.com/jgloss/jar.html#CLASSPATH>
These are FAQs.
- Why doesn't `java -cp $somepath -jar foo.jar AppClass' work?
- How do I include other JARs in the classpath for my JAR-packaged application?
RTFM solves both of them.
--
Lew