Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ClassNotFoundException

0 views
Skip to first unread message

Roberto Nunnari

unread,
Nov 17, 2003, 11:53:39 AM11/17/03
to
Hi there.

could any kind soul help please? Can't understand what's wrong here..

here's my configuration:

-bash-2.05b$ uname -a
FreeBSD pcm2028.dti.supsi.ch 5.1-RELEASE-p10 FreeBSD 5.1-RELEASE-p10 #0:
Thu Nov 13 23:31:02 CET 2003
ro...@pcm2028.dti.supsi.ch:/usr/obj/usr/src/sys/GENERIC i386

-bash-2.05b$ java -version
java version "1.4.2-p5"
Java(TM) 2 Runtime Environment, Standard Edition (build
1.4.2-p5-root_14_nov_2003_14_29)
Java HotSpot(TM) Client VM (build 1.4.2-p5-root_14_nov_2003_14_29, mixed
mode)

-bash-2.05b$ echo $CLASSPATH
/usr/local/share/java/classes/mysql-connector-java.jar

-bash-2.05b$ jar tvf
/usr/local/share/java/classes/mysql-connector-java.jar Ś grep
org/gjt/mm/mysql/Driver
336 Tue Oct 07 17:51:54 CEST 2003 org/gjt/mm/mysql/Driver.class

-bash-2.05b$ java -jar ChatServer.jar
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
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 com.blitzsoft.chat.ChatServer.main(ChatServer.java:489)

and here's the offending code:

try {
Class.forName( "org.gjt.mm.mysql.Driver" );
}
catch( ClassNotFoundException e ) {
e.printStackTrace();
}

Any Ideas?
--
Roberto Nunnari -software engineer-
mailto:roberto.nunnari@su_REMOVETHIS_psi.ch
Scuola Universitaria Professionale della Svizzera Italiana
Dipartimento Tecnologie Innovative
http://www.dti.supsi.ch
SUPSI-DTI
Via Cantonale tel: +41-91-6108561
6928 Manno """ fax: +41-91-6108570
Switzerland (o o)
=======================oOO==(_)==OOo========================

_______________________________________________
freebs...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "freebsd-java...@freebsd.org"

Matthew Seaman

unread,
Nov 17, 2003, 12:08:32 PM11/17/03
to

--EuxKj2iCbKjpUGkD
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Nov 17, 2003 at 05:52:10PM +0100, Roberto Nunnari wrote:
> and here's the offending code:

>=20


> try {
> Class.forName( "org.gjt.mm.mysql.Driver" );
> }
> catch( ClassNotFoundException e ) {
> e.printStackTrace();
> }

Hmmm... Try:

Class.forName("com.mysql.jdbc.Driver").newInstance();

The org.gjt.mm.mysql hierarchy is just there for backwards
compatibility nowadays. More detailed instructions can be found in
/usr/local/share/doc/mysql-connector-java/README (or you can extract
that README file from the .jar if necessary).

Cheers,

Matthew

--=20
Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks
Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey Marlow
Tel: +44 1628 476614 Bucks., SL7 1TH UK

--EuxKj2iCbKjpUGkD
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQE/uQApdtESqEQa7a0RAsUpAJ4oLePoVIYQkaHGGf1MIRnFk62z0QCdGZVl
4uB6JhAWnndOusRQaRDzd5k=
=CFtY
-----END PGP SIGNATURE-----

--EuxKj2iCbKjpUGkD--

Roberto Nunnari

unread,
Nov 17, 2003, 12:10:38 PM11/17/03
to
David Bullock wrote:

> On Mon, 17 Nov 2003, Roberto Nunnari wrote:
>
>
>>Hi there.
>>
>>could any kind soul help please? Can't understand what's wrong here..
>
>

> When you use "java -jar", any "-classpath" or $CLASSPATH is ignored.
>
> Either set the value of the 'Class-Path:' manifest entry
> when you build the jar, or use simply:
>
> java -cp my.jar driver.jar org.example.Main
>
> cheers,
> David.

Yes! That works! :D Thanks.

Just one doubt.. why does it work on Windows, then?

Ciao.


--
Roberto Nunnari -software engineer-

mailto:roberto...@supsi.ch

0 new messages