I have written a scientific java application that uses JDBC to
connect to a database. Development was done with MySQL on localhost
(also on unix server), but then we ported the database to Apache
Derby (which is written in Java and allows embedding), in order to
distribute both app and database together (for free). So far, so
good. I can run the app as jar file - or as a Mac application
package - with the db in a folder in the same directory. However, I
would rather hide the database from the user (especially as it is
a folder/directory with zillions of files and subdirectories),
within the app package. The way that the jdbc works (correct me if
I'm wrong), I was unable to communicate with the db if I included
it in the jar file containing the class files, but I could access
it in the Resources directory in the .app if I set WorkingDirectory
as $APP_PACKAGE/Contents/Resources/Java in the Java section of the
Info.plist.
However I have an option in the application to save the graphics
that the app displays in png format. When I invoke this from my
application package the default location to save to is the
WorkingDirectory specified above - ie within the app.
(slightly abbreviated)
Thanks for the replies.
Adrian pointed me back to the ability to specify a path to the db in
the JDBC connection string:
jdbc:derby:/path/to/derbydb
instead of:
jdbc:derby:derbydb
But this only worked for me outside an application package. However
he also pointed me to the ability to set Derby's home directory,
which was key info in the context of Greg's suggestion:
Once you know what to configure Derby with, I suggest the following.
First, DO NOT change the WorkingDirectory property in Info.plist.
Instead,
define a name/value pair in the Properties dictionary, with a value
of:
$APP_PACKAGE/Contents/Resources/Java/derby/
or whatever dir inside the app-bundle you want to use to store the
Derby files.
So I left the connection string as it was (jdbc:derby:mydb) and
removed the Working Directory spec from the info.plist file and
instead added the following name/value pair to the Java Properties
dictionary in the inof.plist file:
which, to my amazement (as I wasn't sure the derby.system.home would
work in this context) worked first time. Seems a bit slower, but
that's probably my imagination. Not sure that the Java directory is
the best place, either, but hell it works and the png files are saved
outside the package.
btw, the app is such that the db is being used as read-only, so the
permissions considerations don't apply.
Greg also wrote:
The file-chooser from the Quaqua PLAF is much more Mac-like.
Google for it.
It can be used by itself, without using the rest of the PLAF
I have seen Quaqua, but writing Java for cross-platform use, I didn't
feel I could go that route 100%. Final Mac tweaking, however, is
different. I'll definitely have a look at it.
And finally, I need to try to do the same thing for Windows (you know
how it is). Need to look at my exe4j (which I find convenient as
there isl a Mac version) which I use to generate .exe files and see
if I can get it to work with the db. I had no joy at all last time I
tried, but I might do better now. However. If anyone has any hints...
Thanks again for all the help. This is an insanely great list.
David
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden