Re: path and classpath settings - Mailing list pgsql-jdbc

From Lew
Subject Re: path and classpath settings
Date
Msg-id hmch90$91v$1@news.albasani.net
Whole thread Raw
In response to path and classpath settings  (shilpa r <shilpar1800@gmail.com>)
List pgsql-jdbc
shilpa r wrote:
> am working on postgreSQL
> i [sic] wanted to know the path and CLASSPATH settings on the environbment
> variable of Xp

For JDBC, the PATH environment variable ("envar") is not relevant.  While you
can include the PostgreSQL JDBC JAR file in the CLASSPATH, for most purposes
that is too much.  The CLASSPATH envar affects every Java program that doesn't
override it, including in your case any that do not really need the Postgres
JDBC JAR.

Much better would be to use the "-classpath" or equivalent "-cp" option to the
"java" command line, or the equivalent if you are using an application server
like Tomcat or Glassfish.  You should read up on the document for how to set
the classpath for a program within your environment, e.g., through the
tutorials and other documentation at java.sun.com.

> as am stuck up with an error stating ClassNotFoundException
> when am trying to connect to Database thru an java [sic] code

Do you have the JDBC JAR on your system?  If not, it's available from
<http://jdbc.postgresql.org/>

After that, it's a matter of including it in the classpath the same way you
would any other library JAR:

ordinary command line: "-cp" as stated above

using "java -jar": in a directory relative to the application's JAR and
specified by that main JAR's manifest.  (Using "java -jar" the JVM ignores any
CLASSPATH or "-classpath" specifications.)

Deploying to an application server: In the "WEB-INF/lib/" directory of the WAR
or the equivalent for an EAR.

It is a powerful thing to know how to specify the classpath for a Java program.

--
Lew

pgsql-jdbc by date:

Previous
From: John Abraham
Date:
Subject: Re: NoSuchMethodError org.postgresql.core.QueryExecutor.startCopy(String)
Next
From: Achilleas Mantzios
Date:
Subject: Very Dangerous bug in XA connection pooling and SL EJBs with jboss-4.2.3 & latest postgresql-8.4-701.jdbc3.jar