Hi All,
I have a java .class file which I have packaged into a .jar file.
The class connects to our oracle DB using one of the Oracle thin
drivers.
This works fine from outside of the jar file. The driver is the
CLASSPATH and the .class file works fine.
However, after packaging the class into a jar and running the jar, I
get the following error.
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at SQLCommands.connectSPINS(SQLCommands.java:440)
at multiInsert04.validateUserID(multiInsert04.java:594)
at multiInsert04.insertDirs(multiInsert04.java:66)
at multiInsert04.main(multiInsert04.java:668)
Is there are way to package the driver within the jar file to prevent
this error?
hilz - 24 Sep 2004 22:30 GMT
> Is there are way to package the driver within the jar file to prevent
> this error?
looks like the driver jar is not included in the classpath.
you need to add the driver jar in your class path, and i can think of two
places:
1) either in the launching command
2) or in the mainfest file or your application jar
hilz - 24 Sep 2004 22:31 GMT
> > Is there are way to package the driver within the jar file to prevent
> > this error?
[quoted text clipped - 4 lines]
> 1) either in the launching command
> 2) or in the mainfest file or your application jar
correction:
2) or in the mainfest file OF your application jar
David G - 24 Sep 2004 23:20 GMT
> > > Is there are way to package the driver within the jar file to prevent
> > > this error?
[quoted text clipped - 7 lines]
> correction:
> 2) or in the mainfest file OF your application jar
So, thats what that file is for :)
hilz - 25 Sep 2004 05:13 GMT
> So, thats what that file is for :)
which file is for what?
if you're talking about the manifest file, it is for this, and more.
see
http://java.sun.com/docs/books/tutorial/jar/basics/manifest.html
Gerard Krupa - 27 Sep 2004 08:52 GMT
> Hi All,
>
[quoted text clipped - 7 lines]
> However, after packaging the class into a jar and running the jar, I
> get the following error.
If you're running the .jar file using the -jar flag then any classpath
specified on the command-line on in an environment variable will be
ignored. You can either add a classpath entry in the manifest (already
mentioned elsewhere in this thread) or use the boot class path with the
-Xbootclasspath/a: flag.
HTH
Gerard