CLASSPATH not working

S

Steven Green

I am trying to get my application to run outside of Eclipse.

I use JDBC and load a driver at runtime.
The application works fine in the IDE where I have the driver jar file
specified, but if I try to run the application outside of Eclipse it fails.

I have tried this on both Linux and Windows XP with the same result.
"Class not found" when trying to load the driver.

I have used -cp, -classpath, and CLASSPATH (environment variable) with the
same result. The driver jar file is not being registered.

I listed the System Properties and printed out all the values under both
eclipse and outside of eclipse. Inside Eclipse the jar is listed properly
under the classpath, but outside (no matter how I specify it) it isn't
registering.

A search of the web found a similar problem, but no resolution.

Any ideas?

Thanks,

Steve
 
W

Wendy S

Steven Green said:
I am trying to get my application to run outside of Eclipse.
I have used -cp, -classpath, and CLASSPATH (environment variable) with the
same result. The driver jar file is not being registered.

Give some examples of what you're typing and the errors you're getting,
probably someone will spot the problem.
 
S

Steven Green

I have gotten this working by copying the driver jar file into
{JAVAHOME}/jre/lib/ext but I think this should still have worked using the
classpath.

An example of what I tried on Linux is as follows:
java -classpath /home/steve/pg73jdbc3.jar -jar test.jar
 
D

David Zimmerman

Steven said:
I have gotten this working by copying the driver jar file into
{JAVAHOME}/jre/lib/ext but I think this should still have worked using the
classpath.

An example of what I tried on Linux is as follows:
java -classpath /home/steve/pg73jdbc3.jar -jar test.jar

On Mon, 29 Sep 2003 16:08:06 -0700, Wendy S wrote:

When you use -jar, both the CLASSPATH env variable and the -classpath
option are ignored. The classpath is specified on the manifest in the jar
 
S

Steven Green

I can understand this explanation, it sure explains what is going on, but
doesn't it seem to be the wrong solution overall. I mean how does someone
specify a JDBC driver if they cannot use the CLASSPATH. I hate to think it
needs to be installed in the JAVAHOME directory to get it to work.

Just my 2 cents.
 
D

Dave Glasser

I can understand this explanation, it sure explains what is going on, but
doesn't it seem to be the wrong solution overall. I mean how does someone
specify a JDBC driver if they cannot use the CLASSPATH. I hate to think it
needs to be installed in the JAVAHOME directory to get it to work.

You can either add the path to pg73jdbc3.jar (relative to the location
of test.jar) to the Class-Path header of test.jar's manifest, or you
can set your extension directory from the command line by setting this
(to my knowledge undocumented) system property on the command line:

java -Djava.ext.dirs=/home/steve -jar test.jar

Notice that it doesn't reference pg73jdbc.jar directly, only the
directory that contains it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top