• Post Reply Bookmark Topic Watch Topic
  • New Topic

classpath suddenly doesn't work when classes are JARed  RSS feed

 
David Clapper
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm having puzzling difficulties with the classpath (on a Unix (Solaris) m/c). When I run my program using separate classes, the JVM (1.4.2) resolves calls to my own classes (in my cwd) as well as those of a third-party supplier (.zip file in a different directory) without problems. However, when I JAR those same classes, although the JVM has no difficulty locating my own classes, it suddenly cannot find the third-party classes.
My set up is as follows:
Current working directory:
cwd: /sbdev/users/sbldev/dacla/javaProgs/classes
classpath own classes:
/sbdev/users/sbldev/interfaces/code/crm/lib/CRPInterface.jar
classpath 3rd party .classes: /usr/oracle/product/817/jdbc/lib/classes12.zip
echo classpath environment variable setting:
.:/usr/oracle/product/817/jdbc/lib/classes12.zip:/sbdev/users/sbldev/interfaces/code/crm/lib/CRPInterface.jar
Directory java sources:
/sbdev/users/sbldev/dacla/javaProgs/source/iris/crp/*.java
Directory java classes:
/sbdev/users/sbldev/dacla/javaProgs/classes/iris/crp/*.class
Compile string (run from /sbdev/users/sbldev/dacla/javaProgs/source):
"/apps/j2sdk-1.4.2/bin/javac -d ../classes iris/crp/*.java"
JAR string (run from /sbdev/users/sbldev/dacla/javaProgs/classes):
"/apps/j2sdk-1.4.2/bin/jar -cvmf manifest.txt CRPInterface.jar iris"
Manifest(with carriage return on the end):
Main-Class: iris.crp.CRPInterface
Each source file has the following first line:
package iris.crp
JVM string:
"/apps/j2sdk-1.4.2/bin/java -jar /sbdev/users/sbldev/interfaces/code/crm/lib/CRPInterface.jar"
The code of the first call to an Oracle class occurs is:
Class.forName("oracle.jdbc.driver.OracleDriver");
This statement is contained in my own View class (see stack trace below)
The error mesage logged is:
CRP INTERFACE STARTED ON 29 April 2004, 07:40:21 AM BST
Getting indicators data from IRIS database...
oracle.jdbc.driver.OracleDriver
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 iris.crp.View.getData(View.java:12)
at iris.crp.IRISRunnable.run(IRISRunnable.java:31)
at java.lang.Thread.run(Thread.java:534)
As you can see, the JVM finds my own classes without difficulty, but chokes on the Oracle call. Do I have to include the oracle classes in the jar too?
I've tried setting the classpath as a (Unix) environment variable, as an option for the JVM, and even using the java.class.path system property, but nothing seems to help.
Any ideas? I'm sure it's something really simple but I don't see it.
Thanks in advance
 
Joe Ess
Bartender
Posts: 9443
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The documentation for the java command states quite clearly:

-jar
When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.

Sounds like you could use the -cp command line option to specify the path to the Oracle zip. If that doesn't work, you can always combine the Oracle classes into your jar.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mr. Duck:
Welcome to JavaRanch!
We don't have too many rules round these parts, but we do have our naming policy, which asks that your display name consist of a first and last name, and that it not be an obvious fake. Please head over here and update your name ASAP. Thanks, pardner!
 
David Clapper
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Joe, my excuses Ernest, I have updated my profile.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!