Embed a JRE in a Windows executable

Try to use Avian andProGuard toolkits.Avian allows to embed lightweight virtual machine in you app. Linux, MacOS, Windows and iOS are supported. And ProGuard allows you to shrink large jar file to prepare to embed.


Quite a few options around, commercially this is very good:

http://www.excelsior-usa.com/jet.html

There are two key open source options GCJ and VMKit

http://gcc.gnu.org/java/ andhttp://vmkit.llvm.org/

Other more prolonged paths would include IKVM.NET:

http://www.ikvm.net/

Which is a .NET JVM which can be statically compiled to an EXE

Is there a way to embed both the application, and a JRE, into an .exe file acting as the application launcher (and not as an installer)?

If a commercial tool is ok for you, install4j solves this problem very smoothly (see its "Features" page). It can generate both application launchers and installers.

I'd hate to repeat myself too much, so check e.g. this earlier answer where I plugged it (as installer builder, but it doesn't make much difference here).

Summary / bottom line: install4j can create native .exe launchers that absolutely donot depend on a pre-installed JRE (or any other specific libs), and it offers flexible options for bundling (and detecting) JREs.



JSmooth can do this according to the documentation. I have only tried it without an embedded JRE, but been very satisfied. It is scriptable with ant and we build on Linux.

http://jsmooth.sourceforge.net/features.php


 
   

You might take a look at:http://ulibgcj.sourceforge.net/uswt.htmlIt has micro-swt library that make easy to build GUI usingSWTand have a look atEclipse GCJ Builder

 

Install4j is a great tool for this kink of purpose.Also you could check out JSmooth or launch4j-all though I have tried to bundle jres with JSmooth and was not able to..

 

I know I'm a little late to this party, however it looks like ej-technologies (love their stuff) has a new solution calledexe4j which will do exactly as the OP wanted without any funny business needed.

http://www.ej-technologies.com/products/exe4j/overview.html

If you are working in an OpenSource project, they provide free licenses (you just need to contact them). If it's a commercial project, then a license is required... but at $69 USD for a license, it's darn cheap and worth while imho.

From their website:

If you want your own process name instead of java.exe in the task manager
and a user friendly task-bar grouping, exe4j does the job for you.

exe4j helps you with starting your Java applications in a safe way, displaying
native splash screens, detecting or distributing suitable JREs and JDKs,
startup error handling and much more.



You can convert .jar file to .exe on these ways:

1- JSmooth .exe wrapper:
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.

JSmooth provides a variety of wrappers for your java application, each of them having their own behaviour: Choose your flavour!

Download: http://jsmooth.sourceforge.net/

2- JarToExe 1.8
Jar2Exe is a tool to convert jar files into exe files.Following are the main features as describe in their website:

  • Can generate “Console”, “Windows GUI”, “Windows Service” three types of exe files.
  • Generated exe files can add program icons and version information.
  • Generated exe files can encrypt and protect java programs, no temporary files will be generated when program runs.
  • Generated exe files provide system tray icon support.
  • Generated exe files provide record system event log support.
  • Generated windows service exe files are able to install/uninstall itself, and support service pause/continue.
  • New release of x64 version, can create 64 bits executives. (May 18, 2008)
  • Both wizard mode and command line mode supported. (May 18, 2008)

Download: http://www.brothersoft.com/jartoexe-75019.html

3- Executor
Package your Java application as a jar, and Executor will turn the jar into a Windows exe file, indistinguishable from a native application. Simply double-clicking the exe file will invoke the Java Runtime Environment and launch your application.

Download: http://mpowers.net/executor/

4- Advanced Installer
Advanced Installer lets you create Windows MSI installs in minutes. This also has Windows Vista support and also helps to create MSI packages in other languages.
Download: http://www.advancedinstaller.com/Let me know other tools that you have used to convert JAR to EXE.


你可能感兴趣的:(java)