1
1
12rbah2020-05-05 08:49:21
Java
12rbah, 2020-05-05 08:49:21

Is there any guide on how to compile java files into a binary?

Is there any way to create an executable file from java files and still not ask the user to resume something after installation (let's say he does not have a JVM on the PC). If there is a detailed guide on how to make such an exe, please share it.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sergey Gornostaev, 2020-05-05
@12rbah

You can use jlink to create a distribution version of the program that includes the JRE. This is a standard, officially recommended approach, but you get not one exe's, but a directory with many files and a bat's nickname to run the program.
A real exe can be made using the native-image utility included in Graal, but not all java programs are suitable for this.

V
Vladimir Korotenko, 2020-05-05
@firedragon

https://www.ej-technologies.com/products/install4j...

T
Timur Pokrovsky, 2020-05-05
@Makaroshka007

https://ru.stackoverflow.com/questions/415971/%d0%...

I
Igor Maznitsa, 2020-05-06
@raydac

You won’t be able to make a binary by itself, Java needs a JVM, but you can do a little trick and prepare pseudo-binaries for different OSes using plugins for Maven. Often, ease of launch is important for the user, and not “exactly a binary” (although there was one such case with one Python utility and I had to rewrite it in Golang, since the latter allows you to make exactly a binary).
If you make an application in the form of Spring Boot, then you can make a hodgepodge for different OS using Maven:
- use the launch4j-maven-plugin plugin to make an exe bundle version for Windows
- use the appbundle-maven-plugin plugin to make an app image for Mac OS
- with using Spring Boot plugin to make SH executable for Linux
all of the above will use the installed Java on the user's wheelbarrow, as an example - a utility for broadcasting videos to Kodi
if you want to get rid of the installed JDK, then using jlink (for example, through the mvn-jlink plugin in maven) make cross-platform images and pack with the application , for example, this is what the SciaReto project does

Similar questions
K
KhanTengri2011-06-17 23:56:41
Get from a remote web page?</a> <a class="content__item-button" href="/q/get-title-from-a-remote-web-page"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""> <path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path> </svg> <span class="dark">6</span><span class="dn">Reply</span> </a> </div> </div> </div> </div> </div> <div class="content find"> <p class="find__p">Didn't find what you were looking for?</p><a class="find__btn" href="#!">Ask your question</a> </div> <div class="find sm"> <p class="find__title">Ask a Question </p> <form class="find__form" action="#!"> <input class="find__input" type="text" placeholder="Ask your question here"> <button class="find__btn" type="submit"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 16 16" class="nBqR1"><path fill-rule="evenodd" d="M12.696 7.256L9.657 4.217a1 1 0 00-1.415 1.414l1.344 1.344H3.949a1.001 1.001 0 000 2h5.637l-1.344 1.343a1.002 1.002 0 000 1.415c.391.39 1.024.39 1.415 0l3.039-3.04A.993.993 0 0013 7.975a.997.997 0 00-.293-.708l-.011-.011z"></path></svg></button> </form> <p class="find__span">731 491 924 answers to any question</p> </div> </div> <aside class="banners"> <p>banners </p> </aside> </div> </main> </div> <script src="/assets/theme/js/highlight/highlight.min.js"></script> <script src="/assets/theme/js/app.min.js?_v=20220404145216"> </script> <script>hljs.highlightAll();</script> </body> </html>