Executable Java application (JAR) with database packaged inside - java

I am developing an application with Swing and MySql. I want to distribute it to the clients, where they could run the application on their end/PC without worrying about installing MySql and other technical stuff. So, I thought of bundling JRE and MySql but then I came across Correctly distributing a Java application with database which says it is not preferable to do so. As it would increase the application size on disk, which obviously is an issue.
So, my questions are
How do I achieve the same and what tool and resources should I use.
Is SQLite a good option?
Any help is appreciated.

In my opinion SQLite and Apache Derby (http://db.apache.org/derby/) are both good for such a plan. Some years ago i did such stuff with derby and it's still running. At that time i just packaged the folder that contained the jre, the program, libs (jar's) and the data folder of derby.
As i remember: sqlite was very easy to use whereas derby is more overhead to learn.

Please try using HsqlDb visit the link
[http://hsqldb.org/ ]
Easy to use and you can embed it into your jar.

Related

Distribution of Java developed web application (Maven) to different platform independent users those who may not java on their system?

I am thinking a possible way to distribute a Java-based web application to users. The only solution I got is since I am using maven it is easier to package the project in a .war file and the users on the side needs a JSP/ Servlet containers to run that .war file. Is there any simpler way to distribute the .war file.
Also, I am using a MySQL database for storing the data. Then what happens to the database. How can only I will be the database owner without distributing the database? Do I need a server for that? Sorry for asking two questions.
Please let me know if the questions are not clear.
Thanks a lot.
Seems a little peculiar to distribute a web application to users, since web application by definition should just accessible to users through the web, where you just deploy it yourself once however you want.
This also makes it much easier for users as it removes all the headaches of servlet containers and local server execution since users just need a web browser as well as eliminates the database problem you have.

my java application setup isn't working because of database [duplicate]

I created a java application that is a front end for a MySQL Database using NetBeans and JDBC.
Now after creating the jar file it runs smoothly on my computer (Since I have the MySQL installed) but, if I run the jar on a different computer it won't work since it does not have the DB the application is using and not even MySQL installed.
So the question is, is it possible to add the database to the executable jar so it will run on any computer without the need for any installation of any software (Except for JRE of course) ?
If yes, how do I go about doing so?
Thanks everyone for the help in advance.
Use derby database. It already included in JDK's db folder when you installed the Java on your computer.
If you purely want to use the database without using the MySql then simply using the collections to create database, then you doesn't need any other database client as like MySql. But you need knowledge of Hibernate, Spring etc.

Spring Boot Embedded Tomcat Application As a Windows exe file

I am developing an application using spring boot with embedded tomcat. Once I build this app in to jar file, I can run the application without any issue.
However, I need this application to be wrapped as a windows executable file. And my requirements are as follows.
Should be able to wrap the jar file as a windows exe file
All class files should be hidden or encrypted
Has anyone done this before? Any suggested tool for this?
UPDATE
Thanks to Dmitry in the comments. There has been an article released since this answer with instructions on how to use excelsiorjet specifically with Spring Boot.
https://www.excelsiorjet.com/kb/38/
It's a paid tool(Can be free or reduced cost based on your reason for using it and company size) but for your requirements this seems to be a pretty good option.
http://www.excelsiorjet.com/
Quote from their site
"Excelsior JET enables you to distribute and deploy your Java™ applications as optimized native executables that start and work faster, do not depend on the JRE, and are as difficult to reverse engineer as if they were written in C++."
I used this like 3 or 4 years ago but we weren't too worried about it being decompiled so we ended up using launch4j. I don't remember any problems with it just we didn't wan't to pay how much it cost.

Installation for a college DBMS Project

I have created a simple database application as a part of my college assignment. I have used Java (Eclipse IDE) and MySQL (command-line and phpMyAdmin) for the purpose of creating and using the database on a stand-alone application. The thing is that my database is stored on the localhost.
An easy way to make my application usable on another person's computer would be to convert it into an Executable JAR (since, I am using Java). However is there any way by means of which I can also install the database directly to the other person's computer (on the localhost)?
Something like an installer or so?
I read online that a simple thing would be to manually install MySQL and create the database. But I don't know PHP and typing the MySQL commands / using phpMyAdmin would be the only choice. But is there any better way to go about doing it?
Thanks for any help.
EDIT1:
I don't know if this helps but I have no previous knowledge regarding creating installers for projects. All I have done until now has been exported either as an executable JAR or as source code. I am still studying.
EDIT 2: Creating an installation for a java project <- is a similar question but it does not help my cause. It recommends not using MySQL. Our college has compulsorily asked us to use MySQL and nothing else. That is what they taught us and expect us to work only with it. Please help.
You don't need PHP here, so don't worry about not knowing it. PHP is just another programming language (a web-based interpreted one), and isn't going to help you install MySQL.
You should probably ask your instructor for assistance, because anything we come up with would be a guess about how they intend for your to operate, whereas they know and have done this before many times. That being said, we can make reasonable guesses toward helping you.
You could probably have one master MySQL installation that all your installed Java applications access. This is probably what you want, rather than installing the MySQL application on each individual computer. Your Java application then connects to your college's MySQL server rather than localhost. This requires configuring the MySQL server for remote access, but if that's what they want you to do they probably have already done so.
The other option is to have an installer that actually installs MySQL and runs a series of scripts to import the expected database structure. I can't imagine this is actually the intention, but there are many different installers that can help with this, and it depends how what platform you're developing for as to which automated installation tool might work best for you. You can, to a large degree, script the installation of the official source, so you may simply be able to tweak that once you find the customization options you need, then wrap that in a simple shell script which first installs MySQL then imports your database structure. I can't imagine this is what your school intends, but that's how you would do it if it were. That or Chef, Puppet, or your distribution's built-in package manager. Too many options to cover them all thoroughly here.

Create .exe for java swing app with embedded HSQL

Recently I made an application in using Swing, HSQL Embedded that manages some database. I used HSQL as the backend to connect to the database. What I want to do is create a setup/installer program so that the application can be installed and used on any pc. My problem is I dont know how to integrate the database along?
You can use exe4j to generate .exe.
And wizard4j to create installer for your application.
Problem is that creation of exe is quite isolated case. In case of Windows, you will create msi package, in case of OSX, you will create dmg, in case of Linux, you will create rpm or tar.gz etc. Yes you could use exe4j, install4j etc. But I strongly recommend to put your jar in one specific folder, zip it and distribute in that format.
Now, when it comes to your database "integration", have a look at this question and this documentation. Reason for distributing Java application this way and not with installer come from bad experiences I encountered when writing data into flat file databases after applications get installed via install4j or exe4j.

Categories