aspose file tools*
The moose likes JDBC and the fly likes Setting ojdbc14.jar as classpath. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Setting ojdbc14.jar as classpath." Watch "Setting ojdbc14.jar as classpath." New topic
Author

Setting ojdbc14.jar as classpath.

Willhelm Smith
Greenhorn

Joined: Nov 03, 2010
Posts: 7
Hey guys,

Got a question surrounding classpaths.

I have created a program that depends on the oracle JDBC driver, I have built it in Eclipse and added ojdbc14.jar to the build path. However when I want to run it from the command prompt it says it can’t find the oracledatasource (due to it not being in the classpath).

How do I add the ojdbc14.jar to the classpath on the command line so my runnable jar will work?

I have tried SET CLASSPATH=<dir> and when I type Set Classpath it actually comes up with the ojdbc.jar file however it still doesn’t run.

Cheers

Will
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

This might be of some help. If you want to make your Jar runnable, you will need to set the Class-Path in the jar's manifest file.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Willhelm Smith
Greenhorn

Joined: Nov 03, 2010
Posts: 7
Paul Sturrock wrote:This might be of some help. If you want to make your Jar runnable, you will need to set the Class-Path in the jar's manifest file.


Ok, but I want to be able to set the classpath from the command line so other users can set the classpath of their ojdbc14.jar file.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Do you mean set it from your Java program?
Willhelm Smith
Greenhorn

Joined: Nov 03, 2010
Posts: 7
Paul Sturrock wrote:Do you mean set it from your Java program?


No I mean set it from the command prompt (as in Windows CMD). Basically my program relies on this ojbc14.jar file in order to compare databases. The idea is other users can download the ojdbc14.jar file from the oracle website, add this to the classpath from wherever they have it locally and run my program.
Nikhil Pasupukuntla
Greenhorn

Joined: Jun 04, 2009
Posts: 21
Willll,

In the set classpath=<dir>. Does your dir include jar file name as well? If not try including the jar file name in the path for e.g; set classpath ="c:/example/ojdbc1.4jar"


Nikhil Pasupukuntla
SCJP 1.5 | OCPJWCD 1.5
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 507
Hi,
I think if you create a simple Ant build file and use build.bat to run your program, you can give your users chance to setup the JAR file path conveniently.

regds,
amit
Willhelm Smith
Greenhorn

Joined: Nov 03, 2010
Posts: 7
nikhil pasupukuntla wrote:Willll,

In the set classpath=<dir>. Does your dir include jar file name as well? If not try including the jar file name in the path for e.g; set classpath ="c:/example/ojdbc1.4jar"


Ok its a new day, I was doing this "set classpath =c:/example/ojdbc1.4jar" yesterday and it wasnt working, I thought I would give it a try again and it seems fine, weird! Anyways it is working now.

Thanks for the help guys
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting ojdbc14.jar as classpath.
 
Similar Threads
jdbc connection with oracle 10g
database connectivity
oracle package not found error
Java to Display Data from Database
Error connecting to database from executable JAR file.