Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

application connects to Oracle but executable jar can't

Status
Not open for further replies.

cadoltt

Programmer
Jun 9, 2005
85
CA
Hi everybody!

I need to clarify something. I've created a simple application which connects to an Oracle db and executes a simple Select query. I work with Eclipse and when I run the app from within Eclipse, or I start it from the command prompt window, it goes all right but when I try to run an executable jar, connection fails and I am getting an error message: 'java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver'.

The oracle driver is added to my CLASSPATH variable. Is there anything I have to add to the jar?

Can anyone help?

Thanks,
Alex
 
Isn't clsMain part of a package?
If you use external jars, your classes don't may be in the anonymous (no-name) package.

Specify a package, and change your manifest accordingly:

Main-Class: myPackage.clsMain

Meanwhile I verified, that I used 'ojdbc14.jar' last year, but ojdbc14_g.jar might be ok for you.

seeking a job as java-programmer in Berlin:
 
stefanwagner,

Thank you. I created a package, recompiled the project (made sure it works from a command line), changed the manifest accordingly:

Manifest-Version: 1.0
Class-Path: C:\j2sdk1.4.2_03\oracle_driver\classes12.jar
Main-Class: pckMain.clsMain

...BUT it still refuses to start giving the same message: 'Could not find the main class. Program will exit'

BTW, I don't know if this is important but inside the jar the manifest becomes:

Manifest-Version: 1.0
Class-Path: C:\j2sdk1.4.2_03\oracle_driver\classes12.jar
Created-By: 1.4.2_03 (Sun Microsystems Inc.)
Main-Class: pckMain.clsMain


...Alex
 
And you got a Linebreak after your Main-Class: - statement?

I gave a bad example with 'myPackage.clsMain', because package-names shall be all lowercase, and Class-Names start with Uppercase: (mypackage.ClsMain).
But these are only suggestions. and shouldn't lead to failure.

What is a
Code:
jar -tf your.jar
showing?

seeking a job as java-programmer in Berlin:
 
Guys,

I've just installed Fat Jar Eclipse Plug-In and succesfully built the jar with it. Now it works.

Thank you all for your contribution. Yet I have another question. The jar is about 1 Mb in size, mostly due to oracle driver classes. Is there a way not to place them into there, since I have them on my machine anyway?

Thanks again, and my apologies for so much trouble my problem caused.

Alex
 
stefanwagner,

I think I'll try the trick in spite of existing argument.

Thanks,
Alex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top