A completed Java project, now creating a jar or .exe file (with database)

So, I just finished a small Java application, with a database and so on ... I used Netbeans and Mysql, now I want to export my project so that I can use it wherever I want; any computer, even without installing mysql or java! So, I tried some programs, such as Launch4j or something like that ... but the main problem is that even if I create the .exe file, what will happen to the database? it is on my PC, so if someone tries to use my application, it cannot access the database, so the application will not work ...

In other words ... What is the solution I can use to "Merge" the database with the application, if possible? or create a .exe file with a database ... I hope my problem is clear and thanks for your answers :)

+4
source share
5 answers

You can look at MySQL Connector / MXJ to embed your mysql database in your application.

But keep in mind that this package is no longer under active development:

Due to very low demand, MySQL has stopped developing and supporting Connector / MXJ. Source and binaries for previously released versions will still be available from the archives.

An alternative solution would be to use another database such as SQLite , H2 or HSQLDB

+3
source

You can create an executable jar by exporting the project via eclipse. You can do this by following these steps:

  • Right click on the project
  • Export as a Jar file
+2
source

When you programmed in netbeans, did you include the database in netbeans? Here is a guide on how to do this.

https://netbeans.org/kb/docs/ide/mysql.html

Also included is a second guide to packaging and distributing Java Desktop applications.

https://netbeans.org/kb/docs/java/javase-deploy.html

I hope this helps.

If you do not just follow the step you took to create the application.

+1
source

If you really want to give your users a good experience, I would suggest you implement the built-in database in your application.

Take a look: http://www.h2database.com/

It is free and open source, and I use it a lot. It supports built-in (where it creates flat database files on the computer), in memory and in server mode, where you have the ability to allow multiple applications to share the same database.

This is just a jar file that you add to your application, and then users do not need to install either MySQL, have access to MySQL on a network drive, or install other database software. (depending on your requirements, it might also be a good idea to look into Hibernate to have some abstraction between different DBMSs).

+1
source

To get the database embedded in the application, consider HSQLDB, which is an in-memory database.

http://hsqldb.org/

It can fully work in the JVM without any external resources.

0
source

Source: https://habr.com/ru/post/1500208/


All Articles