简体   繁体   中英

Running a java program as an exe in Windows without JRE installed

I want to run a java program as an exe in Windows. The windows box doesn't install java at all...

So, is there any other way in which the java program can be converted to an exe which removes the need for a dependency on the JRE?

You can use Excelsior JET compiler for that purpose.

Seehttp://www.excelsiorjet.com/ for more information on this.

You can ship the JRE with your application and use that JRE for your application. The effect is the same: The application will be started through an executable (wrapper needed) or script (batch) file and the target machine does not need to have a java runtime installed.

Java doesn't have to be 'installed' , it just has to be 'present' .

For the application to run you will need the runtime. In fact the very first thing that happens when you start the app is a call is a made to OS to start JRE. You cannot do without JRE.

[You can of course embded JRE into your app itself if you want].

I have used JSmooth to exify my application. It also allows for embedding a JRE inside. I just used the "ensure that at least Java X is available".

GPL, can be run as an ant task.

Well given the fact, that you are requesting an executable file (exe) in Windows, there is another approach:

Use IKVM.NET - Bytecode Compiler which converts Java bytecode to .NET dll's and exe's.

Get the latest version of IKVM.NET here .

Use this command

 ikvmc -target:exe -out:foo.exe yourJarFile.jar

to create your .NET executable file.

After this, you can use your exe with the mandatory IKVM dll's or if you prefer one exe file, you can use ILMerge in order to get a single executable file:

ILMerge.exe /target:winexe /targetplatform:"v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1" /out:C:\foo\bar.exe foo.exe <IKVM dll's>.dll

If you are using JDK 9 and above then you can use jlink . It will include all the necessary modules, header files, security policy files, etc, and build a minimal runtime image. This image can be shipped directly to the customer. You can specify your own launcher and what not.

jlink description:

You can use the jlink tool to assemble and optimize a set of modules and their dependencies into a custom runtime image.

Read more at oracle docs: Java Platform, Standard Edition Tools Reference .

GCJ can create native code from Java source files. Here's a tutorial on how to build it in Windows.

Have you tried install4j ? There are various versions, some free, of this concept. Basically, this application compiles your application into an executable installer, specific to the OS of your choice.

Easiest way to do this task is to use the launch4j for the windows exe wrapper and then use inno setup to create the installer. When you are creating the installer for the you application add the folder under the other application files . Make sure jre is inside the folder.

Work done!!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM