views:

327

answers:

6

I have to burn a Java application on a CD. This application have to run on every Windows PC wihtout any installation (also JRE shouldn't be installed) before.

+4  A: 

I guess you could copy the JRE from your programs folder onto the CD too. Then, add a batch script to use your "local" JRE to start your app. That should be enough, but I don't know if this works with all versions of windows.

ZeissS
The problem isn't Windows, that will happily run a Win32 PE executable from anywhere. But does the JRE make additional assumptions?
MSalters
+3  A: 

You'd have to bundle jre on disk and create startup scripts. If you are not satisfied with simple batch / shell startup scripts you can use something like JLauncher to create "real" executable.

Dev er dev
+1. If a commercial tool is ok, install4j is good for creating a .exe launcher (with bundled JRE) for Java apps. See e.g this answer: http://stackoverflow.com/questions/2258932/embed-a-jre-in-a-windows-executable/2258946#2258946
Jonik
Ah, I should've recommended exe4j by the same company instead: http://www.ej-technologies.com/products/exe4j/overview.html Not much difference from technical point of view (when it comes to making launchers), but it costs much less than install4j.
Jonik
+1  A: 

Just burn a jre onto the cd as well and start your application inside a batch script, which sets the CLASSPATH and the JAVA_HOME variables pointing to your jre.

Georg Edelmann
+2  A: 

The easiest way would be to include an unpacked Java installation on the CD and use it to run the application.

There are AFAIK only 2 "Java to exe" compilers still on the market, one of which (Excelsior JET) is quite expensive, and the other (GCJ) doesn't work on Programs that use AWT or Swing.

Michael Borgwardt
Also (at least) install4j does "Java to exe". To my knowledge it's the best of Java installer/launcher tools.
Jonik
@Jonik: The software Michael Borgwardt was referring to are compilers, that create native code out of Java-Sources. install4j creates an exe-launcher for starting the Java-Bytecode with the proper JVM. That should be sufficient in most cases, but isn't really the "Java to exe" that Michael had in mind.
Mnementh
@Mnementh, ah, thanks for clarification. Looking at the original question, I don't think OP would need real "Java-to-native-code" though.
Jonik
@Jonik: What does it actually do? I couldn't tell from the worthless marketing BS on their homepage. An installer is not what's wanted here, nor a launcher that looks through the system for existing JREs.
Michael Borgwardt
Launcher **with bundled JRE**. (For example; this happens to be what OP needed.) See my comment in http://stackoverflow.com/questions/2712768/how-to-make-java-application-standalone/2712792#2712792. Their "features" page actually isn't marketing BS at all: http://www.ej-technologies.com/products/install4j/features.html (I've used this tool myself and know that it *is* good.)
Jonik
+3  A: 

JSmooth can do the trick with bundling JRE or prompting install Java, and it is free. You can also set properties for JVM

Xorty