tags:

views:

215

answers:

6

Hi Folks,

I created an java apllication. i created the Excecutable jar and Exe files for my application. But it cant be run at a system which not installed computer. How to do it? Is there any possible to configure the JRE in the EXEcutable jar or Exe file itself? Any Idea?

+2  A: 

You can't package a JRE inside a Jar, but you could package one alongside your jarfile and have your installer manage the installation. Sun/Oracle allows redistribution of the JRE just for this purpose (systems that don't have one).

Chris Kaminski
As an aside, this is one of those instances I wish Sun had paid Microsoft some money to update the JRE in XP/Vista/7. Sigh...
Chris Kaminski
+1  A: 

Yes, one can create an OS-specific executables from java applications, there have been some question already about this topic, like here: http://stackoverflow.com/questions/2258932/embed-a-jre-in-a-windows-executable

Java is always compiled to a OS-independent byte code that can only be executed in a Java Virtual machine, like the one that comes with the JRE.


Just because you tagged your question with 'eclipse' and mentioned an 'exe' file ... just in case, you created an eclipse RCP application, then there is an elegant way to bundle the application with a java runtime environment: Just create a folder named 'jre' inside your applications directory (same level as plugin and features folder) and copy a JRE to that folder. There might even be checkbox in the eclipse export pages to bundle the app with a JRE.

Andreas_D
+3  A: 

I think this project : launch4j might be useful to you. It can wrap the jar in an executable and bundle a JRE in making it behave like a native application.

Peter Tillemans
its a window application for the standalone system. Any Idea? it does not have the manifest file. Right? then what to do?
Praveen Chandrasekaran
Create a manifest file. It just a text file with some key value pairs and seldom longer than half a screen. You can fond more info here : http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html
Peter Tillemans
+2  A: 

JSmooth is a Java Executable Wrapper. It creates native Windows launchers (standard .exe) for your java applications. It makes java deployment much smoother and user-friendly, as it is able to find any installed Java VM by itself.

When no VM is available, the wrapper can automatically download and install a suitable JVM, or simply display a message or redirect the user to a web site.

stacker
A: 

You can try to compile it in binary with CGJ. You will have to install Cygwin or MinGW on the host machine from which you want to bundle your app but it's a clear solution since it compiles the whole program in native code.

Take a look here..

Jack
+1  A: 

Yes, this is a subset of of a different question I've answered here. Either a Java aware installer which will package up the JRE and include it, or compiling to "native" (JET, GCJ or IKVM). I've used the last for none-GUI applications and it works rather well.

mlk