Distributing a Java application with an Embedded Apache Derby database - java

So i currently have a java application that uses an Apache derby embedded database to store information regarding the user.
I built the application in Netbeans, and it now resides within the dist folder, the folder contains the executable jar, the Apache database, and the lib folder. so I can launch the application by selecting the executable jar but i don't want to distribute this folder to users, I would rather have a single exe that the user can select instead of giving them the folder that has the executable jarand other folders within it.
I have been looking into tools like launch4j but they don't do what i need.
Is it possible to create a exe that contains a derby database?
EDIT
also I need to write to the database to store users details.

Related

How can I transfer my java NetBeans project connected to SQL management server database to another computer?

Now I have a clinic management system I developed in NetBeans and the project is connected to the SQL server manager. Now I want to copy my project with its connection as a whole so it would work as a desktop application on the other laptop from an icon on the desktop rather than opening NetBeans and running the file. What are the procedures to take to transfer my project and the database and work as a desktop app?
I have faced the same issued; after the project jar built, if you just copy the Jar file to others PCs, it won't work.... You have to copy also a the lib folder in the dist directory where you found the JAR file, it contains the libraries you used while programming

How to put project Input resources outside of JAR like Lib folder

I have project which takes Database SQL queries from text files under project folder. When building JAR file I want to put that scripts folder outside of JAR file, but Jar can Access that queries from scripts folder,
i.e., Like when we build JAR file with Netbeans lib folder for that JAR created separately as libraries
same thing I want with script folder but programs can take queries as Input from that folder.
I'm reading queries from text file because my project queries are of about 20 lines and it will change periodically, so I can't add it in actual Java program also I don't want to create DB Stored procedures for the result.
I have shared my projects directory structure
Any help will be appreciated.

How to ensure only one derby database is created and used by my Jar file?

I have created a JAR file with my java program that uses an embedded derby database. Then I converted that JAR file to a .exe file. Everything works fine except that when I copy the icon to the desktop, all of the database files are saved there when I launch the program. To combat this, I launch it in a separate folder and once the database files are made in that folder I copy a shortcut to the executable onto my desktop. Even after I do this though, the application will not read from the existing database files and it will create new database files on my desktop. How do I make it so that it will read from the files in one location and not recreate it everytime I open it in a new place?

Access derby database in executable jar

I have been looking for a while now but haven't found exactly what I want. So, I have a project written in Java and have created a small Derby database that I have embedded in the project. Now when creating an executable jar of the project, I cannot access the database anymore unless I put the derby database files in the same directory of where the executable jar is located. However, I do not want this, I really want that the database files are INSIDE the jar.
I have tried to put the database files in a package and reference it like that, without any luck. Could someone point out how I can get this to work please?
Thanks!
EDIT
The goal here is that I want to create more than one executable JAR file and upload them to a Sun Grid Engine and execute each jar with different parameters. However, they all need to be able to access the database and until now I get an error when 1 application already booted the derby database, another application cannot access it. Therefor ALL jar files need to have their own database.
Do you use the jdbc:derby:jar protocol to access your database?
According to the documentation what you're after should be possible.
Inside your app (the one going into the executable jar) you must access the database using the jdbc:derby:jar protocol.
Create the database with the desired content.
When you have built your jar, you can use jar commands to add the database dir to your jar.
All of this could go in your build script, obviously..
There may be issues related to jar sealing and such, YMMV.

Distribute a database made with JavaDB with Java program

I'm creating a program in Java in which I have to use a lot of tables.
I made the decision to create all those tables in a JavaDB file.
However, now I want to distribute this filled JavaDB file with my JAR file
for distribution, since connecting to a server is not an option.
In the past I could only distribute an empty database with the JAR
by using that Derby package.
Any ideas?
Thank you so much!
I'm not sure I understood the question but it is possible to package a read-only database inside a JAR. From the derby documentation:
Accessing Databases-in-a-Jar in the Class Path
Once an archive containing one or more
Derby databases has been created it
can be placed in the class path. This
allows access to a database from
within an application without the
application's knowing the path of the
archive. When jar or zip files are
part of the class path, you do not
have to specify the jar subsubprotocol
to connect to them.
To access a database in a zip or jar
file in the class path:
Set the class path to include the jar or zip file before starting up
Derby:
CLASSPATH="C:\dbs.jar;%CLASSPATH%"
Connect to a database within the jar or zip file with one of the
following connection URLs:
jdbc:derby:/databasePathWithinArchive
(standard syntax)
jdbc:derby:classpath:/databasePathWithinArchive
(syntax with subsubprotocol)
For example:
jdbc:derby:/products/boiledfood
jdbc:derby:classpath:/products/boiledfood
If this doesn't answer the question, please clarify.

Categories

Resources