Cross platform installer for Java

L

Lionel

Hi all,

I'm nearing on completion of my first major Java project. Now it's time
to start thinking about an installer. I have never written an installer
before. The application is fairly simple, here's what I think the key
parts are:

Single jar file contains the program.
The program uses a compiled jasper report file.
The program needs to know it's working directory and have a location
where it can temporarily save an image file for use by the report.
The program requires several third party jar files.
The program requires MySQL to be installed.
The program requires java 1.5 or later.

The installer must be cross platform, supporting at the very least Linux
and Windows. I would like to check to see if there is valid JRE and
MySQL installed, if not, install them, preferably automatically although
license agreements may not allow this . . . I will follow that one up.

I'm prepared to do the research and reading to figure out the best
approach, but I need a kick start as to what I should be looking at. Any
tips etc. would be great. Things like should I use a scripting language
and so on.

Thanks

Lionel.
 
O

Oliver Wong

Lionel said:
Hi all,

I'm nearing on completion of my first major Java project. Now it's time to
start thinking about an installer. I have never written an installer
before. The application is fairly simple, here's what I think the key
parts are:

Single jar file contains the program.
The program uses a compiled jasper report file.
The program needs to know it's working directory and have a location where
it can temporarily save an image file for use by the report.

This doesn't seem to be the responsibility of the installer. The
application should be able to get a temporary file File.createTempFile(). As
for the current working directory, I think that depends mainly on how the
user invokes the program.
The program requires several third party jar files.
The program requires MySQL to be installed.
The program requires java 1.5 or later.

The installer must be cross platform, supporting at the very least Linux
and Windows. I would like to check to see if there is valid JRE and MySQL
installed, if not, install them, preferably automatically although license
agreements may not allow this . . . I will follow that one up.

I think install Java and/or MySQL is significantly different between
Linux and Windows (and probably on MacOS too, to some degree). It might be
that the easiest solution is to actually ship multiple installers with your
product, and have the user select the one that's appropriate for them.
I'm prepared to do the research and reading to figure out the best
approach, but I need a kick start as to what I should be looking at. Any
tips etc. would be great. Things like should I use a scripting language
and so on.

If you do find a way, be sure to post your solution to let us all know.

- Oliver
 
L

Lionel

Oliver said:
This doesn't seem to be the responsibility of the installer. The
application should be able to get a temporary file
File.createTempFile(). As for the current working directory, I think
that depends mainly on how the user invokes the program.

Yeah, you're right. I don't know why I included that :).

I think install Java and/or MySQL is significantly different between
Linux and Windows (and probably on MacOS too, to some degree). It might
be that the easiest solution is to actually ship multiple installers
with your product, and have the user select the one that's appropriate
for them.

They certainly are different for Linux and Windows, I haven't used a Mac
so I'm not sure about that. You may be right about using multiple
installers. I probably don't mind too much about letting the user have
to install Java, but MySQL is a whole lot less straight forward.
If you do find a way, be sure to post your solution to let us all know.

Will do. Thanks for your comments.

Lionel.
 
O

Oliver Wong

Lionel said:
They certainly are different for Linux and Windows, I haven't used a Mac
so I'm not sure about that. You may be right about using multiple
installers. I probably don't mind too much about letting the user have to
install Java, but MySQL is a whole lot less straight forward.

You could use an embedded SQL server instead of MySQL, e.g. Derby or
HSQLDB. http://db.apache.org/derby/ http://hsqldb.org/

You could write some code so that you could easily swap between DB
implementations without modifying the rest of your Java code. When the app
installs, by default, it'd use your internal DB (e.g. HSQLDB). You'll
provide a README file that explains how to edit XML configuration files to
disable your internal DB and use an external one such as MySQL instead.

So users who don't want to bother with setting up a DB will have an
application that "just works right out the box", while power users who want
a higher performance DB can switch to MySQL, ProgreSQL Oracle, or whatever
they've already got installed on their system.

- Oliver
 
L

Lionel

Oliver said:
You could use an embedded SQL server instead of MySQL, e.g. Derby or
HSQLDB. http://db.apache.org/derby/ http://hsqldb.org/

You could write some code so that you could easily swap between DB
implementations without modifying the rest of your Java code. When the
app installs, by default, it'd use your internal DB (e.g. HSQLDB).
You'll provide a README file that explains how to edit XML configuration
files to disable your internal DB and use an external one such as MySQL
instead.

So users who don't want to bother with setting up a DB will have an
application that "just works right out the box", while power users who
want a higher performance DB can switch to MySQL, ProgreSQL Oracle, or
whatever they've already got installed on their system.

That's an interesting point. Currently supported is MySQL and Postgres,
possibly some others will work too.

One point to make is that this application is for use in hospitals. So
it's not the sort of thing that is going to be downloaded 100 times a
day and installed. Once installed it should stay there for a long time.

I'll have a look into your suggestion to see if it is suitable.

Lionel.
 
A

Andrew T.

Lionel wrote:
....
I'm nearing on completion of my first major Java project. Now it's time
to start thinking about an installer. ....
Single jar file contains the program.
The program uses a compiled jasper report file.
The program needs to know it's working directory and have a location
where it can temporarily save an image file for use by the report.

Oliver addressed that point, but if you need to write and
access more permanent files, it is better to store them
relative to user.home than the application directory.
The program requires several third party jar files.
The program requires MySQL to be installed.
The program requires java 1.5 or later.

Assuming Java 1.3+ is on the PC, JWS is a good
option for this deployment.

Once it upgrades the user to 1.5 (if needed) it can
even run an installer for the database on first invocation -
specific to the platform, of course.
The installer must be cross platform, supporting at the very least Linux
and Windows. I would like to check to see if there is valid JRE

Assuming the user already has a 1.3+ JRE, that is not a problem.

HTH

Andrew T.
 
L

Lionel

Andrew said:
Lionel wrote:
...

Oliver addressed that point, but if you need to write and
access more permanent files, it is better to store them
relative to user.home than the application directory.


Assuming Java 1.3+ is on the PC, JWS is a good
option for this deployment.

Once it upgrades the user to 1.5 (if needed) it can
even run an installer for the database on first invocation -
specific to the platform, of course.

Ok, I'm checking out what Java Web Start can do for me. I'm not sure if
it is a fair assumption that it is installed though?

Lionel.
 
A

Andrew T.

Lionel said:
....
Ok, I'm checking out what Java Web Start can do for me.

Everything on your requirements list.
..I'm not sure if
it is a fair assumption that it is installed though?

Are you asking me what your users will be using?
I do not know.

If it is not installed, that is trickier at the start.

There are a variety of possibilities to get the user to basic
1.3+ Java, one of which is to put some links
'You need the Java plug-In for this, download <here>'
and perhaps a little JavasScript (for a nicer user experience)
in a web page.

You could provide the web page off the net, or off the
installer disk.

HTH

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top