Compiling Java to Platform specific executable

S

Snyke

Ok what I'm trying to do is distribute a small application across
various platforms, the problem is that most users do not know what to
do with the *.class-files. Since the application should work as easy as
possible I'm now wondering how to best ship the application:
- Java Web Start is not a real option for this application since it
will be run at scheduled times automatically.
- Java Archive on the other hand are, but some packaging software are
claiming that this is a compressed archive (such as Winrar) and
therefore *.jar files may be associated with the packaging software
instead of the Java Runtime Environment.
- I already thought about building a small C++-Wrapper using JNI but
I have no experience at all using them...

So this is the question: what', in your opinion, the best way to ship
Java Software?
 
J

Jason Herald

I think the JNI option is the best way to distribute for Windows.
For Mac just ship the JAR and it will run with a simple double click.

Unfortunatly i dont have any suggestions for linux.

--
If you have any additional questions or need source code email
(e-mail address removed).

Thanks

Jason Herald
 
S

Snyke

Thank you very much, I think I'll try to write a small wrapper in C++.
Do you know a good beginners tutorial to JNI btw?
 
T

Thomas Kellerer

Snyke wrote on 03.04.2005 18:41:
Thank you very much, I think I'll try to write a small wrapper in C++.
Do you know a good beginners tutorial to JNI btw?
The source code for the (Windows) JDK also includes the source for javac.exe
This is exactly what you need. It loads the JVM and starts a specific main
class.

Thomas
 
M

Martin Hedler

Snyke said:
So this is the question: what', in your opinion, the best way to ship
Java Software?

Did you try a script file? For example batch in windows or a shell
script in linux.

Martin
 
S

Snyke

I know a lot of the people coding Java use Scripts to start their
Programs but there are a number of points to keep in mind when using
Scripts:
Scripts work really nicely on Linux, but Linux Users generally know how
to type in 'java myClass' so there is not really a point of making a
wrapper at all. While on Windows, all I could use would be a really
ugly Batch-file (which I hate, they are just too primitive...), which
in some cases won't work.

I think I'll go for the JNI solution since it allows me to check wether
Java is installed before actually loading any Java related stuff and
last but not least I can do an autoupdate of the Java-Classes without
need for a restart :D

Thanks to all of you for your time :p
 
A

Andrew McDonagh

Snyke said:
I know a lot of the people coding Java use Scripts to start their
Programs but there are a number of points to keep in mind when using
Scripts:
Scripts work really nicely on Linux, but Linux Users generally know how
to type in 'java myClass' so there is not really a point of making a
wrapper at all. While on Windows, all I could use would be a really
ugly Batch-file (which I hate, they are just too primitive...), which
in some cases won't work.

I think I'll go for the JNI solution since it allows me to check wether
Java is installed before actually loading any Java related stuff and
last but not least I can do an autoupdate of the Java-Classes without
need for a restart :D

Thanks to all of you for your time :p

Why bother rolling your own wrapper?

There's plenty of off the shelf installation tools that do exactly this
and more, like shortcuts and program groupings.

InstallAnywhere is one example - it allows you to create install
programs for all of the major OSs and platforms.


As for autoupdate - this is an all together different task to installation.

A java app can download new classes from a server and reload them using
a clasloader. However, regardless of how the new class files are
downloaded, your application will have to stop its processing in order
for the new classes to be loaded by the JVM.

This 'stop' could be more like a pause, but the main job of the app is
going to have to be stopped regardless of what mechanism you use to do
the download.

If autoupdate is necessary, then Webstart is actually the first way I
would go. You say that webstart isn't viable because the app is run at
scheduled times (which is a bit weird seeing as above you mention not
wanting to restart the app), but thats easy enough, make the scheduling
part of the app, rather than using the OSs task scheduler.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top