pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Lew <noone@lwsc.ehost-services.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: path and classpath settings
Date: Sat, 27 Feb 2010 20:35:30 -0500
Message-ID: <hmch90$91v$1@news.albasani.net> (raw)
In-Reply-To: <4eb297411002250011i3171f196xffd3297f5fd5fb6b@mail.gmail.com>
References: <4eb297411002250011i3171f196xffd3297f5fd5fb6b@mail.gmail.com>

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



view thread (2+ messages)

Message-ID: <hmch90$91v$1@news.albasani.net>
Permalink:  ../hmch90$91v$1@news.albasani.net/
Also on:    postgresql.org/message-id/hmch90$91v$1@news.albasani.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: noone@lwsc.ehost-services.com
  Subject: Re: path and classpath settings
  In-Reply-To: <hmch90$91v$1@news.albasani.net>
  References: <4eb297411002250011i3171f196xffd3297f5fd5fb6b@mail.gmail.com> <hmch90$91v$1@news.albasani.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox