Embed a JRE in a Windows executable?

筅森魡賤 提交于 2019-11-26 11:41:36
i_home

Try to use Avian and ProGuard 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.

There's a new tool that does this: Packr
https://github.com/libgdx/packr

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/ and http://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

Jonik

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 do not depend on a pre-installed JRE (or any other specific libs), and it offers flexible options for bundling (and detecting) JREs.

Netbeans allows a Java SE project to be packaged in a native application installer, embedding a JRE. It's here :https://netbeans.org/kb/docs/java/native_pkg.html :)

I know I'm a little late to this party, however it looks like ej-technologies (love their stuff) has a new solution called exe4j 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.

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.html It has micro-swt library that make easy to build GUI using SWT and have a look at Eclipse 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 found Engima Projector x86 / x64 better than BoxedApp Packer

If you get soft miminizejre by packr than copy your application myapp.jar into launcher\jre\bin\

and copy from installed jre example C:\Program Files\Files\Java\1.8.0_xxx\bin\javaw.exe to launcher\jre\bin\

Open Engima Protector input -> javaw.exe from launcher\jre\bin\

And go Options if you want high compress and Find Miscellaneous -> Command line "-jar myapp.jar"

And click protect and wait for whole dlls and jar into exe

Make sure your myapp.jar should generate by Eclipse with "Package required libraries into generated JAR" because you don't worry if you have imported many libraries example lwjgl or JavaFX than you must check if embedded javaw_protected.exe has included important files example assets.

But BoxedApp Packer is same too BoxedApp Packer is bit bigger than Engima Protector. Protector is almost best small embedding javaw.exe with assets / resources. Than they can't crack jar files... I hope you are happy with own jar into exe as less 4 mb without lib directory - If you have problem with jvm.cfg error message It means you don't copy embedded exe into root directory of jre or jdk

Please make sure embedded exe is here outside of jre or jdk root directory.

I hope you haven't problem if you use Protector x86 than it need use i586, Protector x64 for jre x64

If you use Protector x64 with jre x86/i386 - It is okay no problem. It works fine.

Best regards

// EDIT:

UPDATED NEW VERSION EXCELSIOR JET + VIRTUAL BOX OR PROTECTOR are almost best "embedded applications"

Check youtube: https://www.youtube.com/watch?v=ctbIxq-1MGE

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!