CodeGuy
CodeGuy

Reputation: 28907

Packaging up a project for deployment - Java

I have a Java application (a quite large one with many external .jar dependencies as well as dependencies on images) and I need to package it up so that someone can double click to run, for example. Or something easy like that.

It uses Java Persistence, so it requires a sql connection which is specified in the Persistence.xml file in the Java Project.

How can I package this up? I was thinking:

  1. the installation process should validate that the user has MySQL installed and if not, direct them to install it
  2. the installation process could ask the user to enter credentials for any database and then I could update the Persistence.xml at run time

These were two ideas I had...but I wasn't sure if there was a known solution to this problem. Any help would be much appreciated!

Upvotes: 0

Views: 732

Answers (3)

Milad Naseri
Milad Naseri

Reputation: 4118

I think you should take a look at embedded database solutions, like H2. Also, you can package your application using maven's shadowing or jar plugin, having the jar-with-dependencies profile activated.

This will nicely rid you of checking for database servers running on the client machine, and also will give you the proper means of bundling the application in one nice JAR, albeit a little large.

Maven is a build ecosystem and toolset especially designed for building Java applications and executing the code -- and generally doing whatever else you can imagine that's possible to do with and to your code.

It has a rich API for developing plugins and many developers have exploited this feature. There are numerous plugins for building -- and launching -- and packaging your application as well as helping you manage your applications dependencies.

Maven's shadowing comes in the form of maven-shade-plugin, available here. What it does is that it helps you create a single JAR file from all your dependencies. Also, there is the maven-jar-plugin which offers a profile jar-with-dependencies. It is also accessible from here.

H2, on the other hand is a full-fledged RDBMS. This is the website: http://www.h2database.com/html/main.html, and here is a tutorial.

You can find information on embedding the database here:

I would also suggest you use a combination of H2/Hibernate/Spring which is a very easy setup and provides you with really rich features and an easy-to-use API.

I hope this helps you :)

Upvotes: 1

psabbate
psabbate

Reputation: 777

I wrote an installer using ANT, but has no GUI. Also, I used Iz Pack (good option), so I think that depends on how smart do you want it to be, if you are supposed to use it, or a non-technical person, etc.

Upvotes: 0

Stephen C
Stephen C

Reputation: 718658

Building a sophisticated installer that checks lots of dependencies, and runs on lots of different platforms (which I assume you want) is complicated.

I suggest that you look at an installer generator; see What is the best installation tool for java?

Another alternative that I've seen in a few products is to write a (non-GUI) installer or configurer in a scripting language like Perl.

Upvotes: 0

Related Questions