Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error connecting to database from executable JAR file.

 
Vivek Chaitanya
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

I created a Swing application which uses ojdbc14.jar for connecting to Oracle 9i database.

I can successfully run the application from command line using javac and also from IDE(MyEclipse).

However I am facing issue when I create executable JAR file for my application. I am not able to connect to Database from JAR even after including ojdbc14.jar in CLASSPATH.

Can someone provide resolution for this issue.

Thank you,
Chaitanya
 
Hendy Setyo Mulyo
Ranch Hand
Posts: 219
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How you run the Jar file, by clicking the jar file or using java -jar ... ?
 
Vivek Chaitanya
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hendy

I run by double clicking it.

Thank you,
Chaitanya
 
Vivek Chaitanya
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

Someone please respond.

I need the resolution to this issue badly for my personal project.

Thank you,
Chaitanya
 
Wayan Saryada
Ranch Hand
Posts: 105
IntelliJ IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the actual error message did you get when running your application? Beside configuring a JDBC driver on the classpath have you tried to put a Class-Path entries in your Jar's manifest file?
 
Vivek Chaitanya
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope...I didnt mention Class-Path in my manifest.txt
 
Vivek Chaitanya
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are ways I can mention Class-Path

I think( because I havent yet tried)

Class-Path: C:\oracle\ora92\ojdbc14.jar ( I mean absolute path. Thsi may creat issue if I ship my JAR to another machine where the path of ojdbc14.jar is different.)

What if I have to put ojdbc14.jar in my package structure.Can i give the path starting from com.domainName.projectName.packageName. something liek this?
 
Vivek Chaitanya
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are ways I can mention Class-Path

I think( because I havent yet tried)

Class-Path: C:\oracle\ora92\ojdbc14.jar ( I mean absolute path. Thsi may creat issue if I ship my JAR to another machine where the path of ojdbc14.jar is different.)

What if I have to put ojdbc14.jar in my package structure.Can i give the relative path starting from com.domainName.projectName.packageName. something liek this?
 
Wayan Saryada
Ranch Hand
Posts: 105
IntelliJ IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can put the JDBC jar file in the same location with your application jar and in the manifest file it will be Class-Path: ojdcb14.jar.
 
Vivek Chaitanya
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Wayan.

I will try this and I think it will work.

I missed out Class-Path in my manifest.

Thank you once again.

Regards
Chaitanya
 
Vivek Chaitanya
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By specifying Class-Path in manifest.txt, I can make my executable JAR file work. But I have some issues with this way of making it work.

1. I have to keep ojdbc14.jar file in the same directory as that of my JAR file.

2.My JAR file size is increasing enormously as it also includes classes from ojdbc14.jar

I dont want above two things to happen and I also want to make use of CLASSPATH environment variable. i.e. I want to include ojdbc14.jar in my CLASSPATH and I need to mention that somehow( I dont know how!) in my manifest.txt. Is there any way of doing this?

I tried giving Class-Path: C:\oracle\ora92\ojdbc14.jar ( I mean, absolute path of ojdbc14.jar) in manifest.txt But it is not working this way. I am getting JVM Launch Error stating that "main class not found".

Please let me know how to achieve what I want.

Thank you,
Chaitanya
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic