Unix Technical Forum

java.lang.NoClassDefFoundError

This is a discussion on java.lang.NoClassDefFoundError within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> Hi, Could you help me in my program JAVA with jdbc Postgre I have my simple code import java.sql.DriverManager; ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces jdbc

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-15-2008, 10:59 PM
Becerra Lagos Ana Lilian
 
Posts: n/a
Default java.lang.NoClassDefFoundError

Hi,



Could you help me in my program JAVA with jdbc Postgre

I have my simple code



import java.sql.DriverManager;

import java.sql.Connection;

import java.sql.SQLException;



public class Example2 {

public static void main(String[] argv) {

System.out.println("Checking if Driver is registered with
DriverManager.");



try {

Class.forName("org.postgresql.Driver");

} catch (ClassNotFoundException cnfe) {

System.out.println("Couldn't find the driver!");

System.out.println("Let's print a stack trace, and exit.");

cnfe.printStackTrace();

System.exit(1);

}

}

}



Then I execute :

javac Example2.java



Then I execute

java Example2



but I get

Exception in thread "main" java.lang.NoClassDefFoundError: Example



Wich is my error ?

I copied pg73jdbc3.jar in my path

C:\j2sdk1.4.1_07\lib\

Its have org.postgresql.Driver



Thanks advanted

ana
Este correo es dirigido solo a las personas que aparecen como destinatarios
y puede contener informacion confidencial o privilegiada.
Si usted recibio este correo por error, por favor notificar inmediatamente
al emisor y elimine el correo original. Cualquier otro uso de este correo
esta prohibido.

************************************************** ************************************************** **

This message is for the designated recipient only and may contain privileged or
confidential information. If you have received it in error, please notify the sender
immediately and delete the original. Any other use of the email is prohibited.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-15-2008, 10:59 PM
Nico
 
Posts: n/a
Default Re: java.lang.NoClassDefFoundError

It didn't work for me either. When I put the jar file in my classes directory, it did work.
""Becerra Lagos Ana Lilian"" <exabecerra@nt.entel.cl> schreef in bericht news:3A568BC085A5794983C7118F1A27CDEC2C7C40@epmare xc03.Entelpcs.Entelcorp..com...
Hi,



Could you help me in my program JAVA with jdbc Postgre

I have my simple code



import java.sql.DriverManager;

import java.sql.Connection;

import java.sql.SQLException;



public class Example2 {

public static void main(String[] argv) {

System.out.println("Checking if Driver is registered with DriverManager.");



try {

Class.forName("org.postgresql.Driver");

} catch (ClassNotFoundException cnfe) {

System.out.println("Couldn't find the driver!");

System.out.println("Let's print a stack trace, and exit.");

cnfe.printStackTrace();

System.exit(1);

}

}

}



Then I execute :

javac Example2.java



Then I execute

java Example2



but I get

Exception in thread "main" java.lang.NoClassDefFoundError: Example



Wich is my error ?

I copied pg73jdbc3.jar in my path

C:\j2sdk1.4.1_07\lib\

Its have org.postgresql.Driver



Thanks advanted

ana

Este correo es dirigido solo a las personas que aparecen como destinatarios
y puede contener información confidencial o privilegiada.
Si usted recibió este correo por error, por favor notificar inmediatamente
al emisor y elimine el correo original. Cualquier otro uso de este correo
esta prohibido.

************************************************** ************************************************** **

This message is for the designated recipient only and may contain privileged or
confidential information. If you have received it in error, please notify the sender
immediately and delete the original. Any other use of the email is prohibited.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-15-2008, 10:59 PM
William Lai
 
Posts: n/a
Default Re: java.lang.NoClassDefFoundError

Hi,

Did you try,

java -classpath c:\path\to\pg73jdbc3.jar;. Example2

Have a nice day,
William

Becerra Lagos Ana Lilian wrote:

> Hi,
>
>
>
> Could you help me in my program JAVA with jdbc Postgre
>
> I have my simple code
>
>
>
> import java.sql.DriverManager;
>
> import java.sql.Connection;
>
> import java.sql.SQLException;
>
>
>
> public class Example2 {
>
> public static void main(String[] argv) {
>
> System.out.println("Checking if Driver is registered with
> DriverManager.");
>
>
>
> try {
>
> Class.forName("org.postgresql.Driver");
>
> } catch (ClassNotFoundException cnfe) {
>
> System.out.println("Couldn't find the driver!");
>
> System.out.println("Let's print a stack trace, and exit.");
>
> cnfe.printStackTrace();
>
> System.exit(1);
>
> }
>
> }
>
> }
>
>
>
> Then I execute :
>
> javac Example2.java
>
>
>
> Then I execute
>
> java Example2
>
>
>
> but I get
>
> Exception in thread "main" java.lang.NoClassDefFoundError: Example
>
>
>
> Wich is my error ?
>
> I copied pg73jdbc3.jar in my path
>
> C:\j2sdk1.4.1_07\lib\
>
> Its have org.postgresql.Driver
>
>
>
> Thanks advanted
>
> ana
>
> Este correo es dirigido solo a las personas que aparecen como
> destinatarios
> y puede contener información confidencial o privilegiada.
> Si usted recibió este correo por error, por favor notificar
> inmediatamente
> al emisor y elimine el correo original. Cualquier otro uso de este correo
> esta prohibido.
>
> ************************************************** ************************************************** **
>
>
> This message is for the designated recipient only and may contain
> privileged or
> confidential information. If you have received it in error, please
> notify the sender
> immediately and delete the original. Any other use of the email is
> prohibited.



---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:19 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com