Skip to main content
gamedev.net
🔒 Locked

[java] How do YOU distribute your java?

Started by Pirosan 4 replies 1.2k views
Original Post
Pirosan
Pirosan
I'm looking into many different ways of distributing my Java applications. I have tried Web Start, and JAR files, but I have come across computers who are not properly set up. Lets say for simplicity that I want to use JAR files... How can i set up the user's computer to point JAR files to java, rather than to their uncompressor of their choice? Thanks for the help! I sometimes forget about this when developing Java in eclipse, simply because it does so much of it for me!
Bow before me... for i am l33t!
LorenzoGatti
LorenzoGatti
Quote:
Original post by PirosanHow can i set up the user's computer to point JAR files to java, rather than to their uncompressor of their choice?

Being the user's computer, you can't rely on automatic execution of jar files any more that you can rely on Java Web Start being available.
Executing a bare JAR file also limits the configurability of your application.

Many Java applications come with a shell script (.cmd/.bat or .sh or both) that invokes "java" or "javaw" as appropriate and sometimes initializes commandline options like -classpath and environment variables. This method relies on the user having a JRE installed (reasonable, but not certain) and having added its /bin directory on the system PATH (doubtful).

More sophisticated applications detect what JRE to use at installation time, to give adequate error messages and to avoid depending on the PATH (by adapting the scripts: "c:\jdk1.4.2_05\bin\java -classpath d:\somewhere\the_app" instead of "java").
It is also possible to use an executable program and not a shell script to run Java programs. The configuration problems are the same (these wrappers have a configuration file listing the JRE to be used and the interpreter options), but on Windows an executable provides familiarity for those who have never seen a shell script, custom icons (important for recognizing program windows), and the possibility of running a Java program as a Windows service.

The Apache Tomcat web application server is a nice advanced example; it has multiple complex scripts and executables and a refined installation program.

Omae Wa Mou Shindeiru
princec
princec
I embed the entire JRE inside my application and have a little custom .exe launcher for it. Advantages: flawless. Disadvantages: size.

On the Mac of course just a .app does the trick with a little stub launcher thingy which they explain on the Apple dev site but if you want to just grab one of my games you can tweak the contents of the plist file and the jars and it'll all work out nicely.

Cas :)
Son of Cain
Son of Cain
This is less common, but works as well: to use ant scripts for the entire building.

Of course, this has the limitation of size - you have to distribute ant and ant-swing for those who do not have it (ant-swing is optional) - but, ant is like a swiss knife that gives you much information about a user's system to bail out safely of an installation if need be.

However, princec's method is by far the most reliable, IMHO. If web start were widely spread, it would certainly be the best way to go, but...

For the sake of an example, Hibernate 3 is distributed using ant. Of course, it is not a game, it is a framework, but you can figure out the tweaks a build for a game would require.

Son Of Cain
a.k.a javabeats at yahoo.ca
Cacks
Cacks
Hi,

pricec said he embeds the jre in his apps. How would I do this? And custom exe to run them, would it be in c++?

Thanks for any advice
Reject the basic asumption of civialisation especially the importance of material possessions
SteveTaylor
SteveTaylor
A jre can be embedded using JNI, but I've never done this so I'm not sure how. It would be a matter of writing a very short C or C++ program that would just launch the jre with a parameter list. Perhaps you would need to trap stdout and stderr and either discard or log them.

http://java.sun.com/j2se/1.5.0/docs/guide/jni/index.html

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.