Results 1 to 8 of 8
- 11-29-2011, 07:11 PM #1
Member
- Join Date
- Nov 2009
- Posts
- 90
- Rep Power
- 0
understanding jar files and derby
O.K. I've made some progress in deploying my Derby-based application in a .jar file.
A new problem, however, has cropped up.
I want to package the necessary driver (lib/derby.jar) and database (flashdb) along with my application (flash) in a .jar file (Flash.jar). To this end, I used the following command:
jar cvfm Flash.jar Manifest.txt *class lib/* flashdb/*
where the manifest contains the following entries:
Main-Class: Flash
Class-Path: lib/derby.jar
As long as lib/derby.jar and flashdb are in the same directory as the .jar file, everything runs swimmingly. But if I move only the .jar file somewhere else, the program can't find the driver.
If I view the table of contents of the .jar, the driver appears to be there.
So the question (of the moment) is: How do I set the Class-Path so that it finds the driver (within Flash.jar)?
- 11-29-2011, 09:07 PM #2
Re: understanding jar files and derby
I don't think the java program will search for your jar file. You must specify where it is and leave it there.How do I set the Class-Path so that it finds the driver
- 11-29-2011, 09:19 PM #3
Member
- Join Date
- Nov 2009
- Posts
- 90
- Rep Power
- 0
Re: understanding jar files and derby
So, if I distribute the program, database, driver, etc. in a .jar file, I'll need to extract the database, driver, etc. before the program can access them? I composed a little .bat file to do this. It works, but it isn't very clean.
- 11-29-2011, 09:27 PM #4
Re: understanding jar files and derby
It depends. The java program is would be able to read .class files that are in the jar file.
The OS would need the .dll type of files to be outside of the jar file as separate files.
If the database can be accessed as a resource via a stream, it could be in the jar file. If the classes for accessing the DB only work with files, then the DB would have to be its own file.
- 11-29-2011, 10:00 PM #5
Member
- Join Date
- Nov 2009
- Posts
- 90
- Rep Power
- 0
Re: understanding jar files and derby
The proximate problem appear to be the inability to find the driver in derby.jar, which is part of the .jar file.
What confuses me is that if I issue the command
java -jar Flash.jar
the driver is found, and the database is accessed just fine.
Why should it also not work by just clicking on the .jar file?
- 11-29-2011, 10:04 PM #6
Re: understanding jar files and derby
The OS controls what happens when you click on a file to "open" it. The OS needs to have a commandline template like the commandline you used: java -jar <THEJARFILEHERE> with the name of the jar file being filled in when the OS tries to "open" the file. If the commandline is not set up properly, then the jar file does not execute.
- 11-30-2011, 09:34 AM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: understanding jar files and derby
1. You cannot jar jars in an executable jar. Well, you can, but the JVM cannot access them when executing.
2. Distributions should generally involve your jar and a lib containing dependent jars...after all, if there's a bug in a dependency then why deploy the whole thing? Deliver it as an installer or a simple zip.
3. If you have a db in a jar it will be read only. If that's not a problem then OK, otherwise you'll need to provide that in your distribution as well.
- 11-30-2011, 04:02 PM #8
Member
- Join Date
- Nov 2009
- Posts
- 90
- Rep Power
- 0
Similar Threads
-
Derby Mystery..!!!!
By yiantzi in forum JDBCReplies: 3Last Post: 01-24-2011, 11:59 AM -
Derby.jar
By wulfgarpro in forum New To JavaReplies: 0Last Post: 10-02-2010, 05:22 AM -
derby DB problem
By edi.gotieb in forum Forum LobbyReplies: 8Last Post: 05-17-2010, 12:45 PM -
need some derby tips:
By kulangotski in forum Advanced JavaReplies: 4Last Post: 03-09-2009, 05:09 PM -
using if in derby
By suhaib1thariq in forum JDBCReplies: 0Last Post: 01-25-2009, 04:46 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks