1

I'm doing my first java project and would like to use the JavaFX GUI. I was able to compile it to the executable jar, the problem is that the only one way to run it is to have the jdk-14 computer on my computer( because I use java 14) and use the command "java -jar NameJar.jar". However, I would like to open it by double-clicking the program icon, but I have not found how to do it.I would like to know how to do it so that it opens by double clicking on the icon.

Monterisko
  • 21
  • 1
  • 7
  • This is answered here: https://stackoverflow.com/questions/4330936/how-can-i-convert-a-jar-to-an-exe#:~:text=Package%20your%20Java%20application%20as,Environment%20and%20launch%20your%20application. – stringy05 Jun 18 '20 at 23:15
  • 1
    Related Q&As: [How to deploy a JavaFX 11 Desktop application with a JRE](https://stackoverflow.com/questions/53453212/), [JavaFX 11 : Create a jar file with Gradle](https://stackoverflow.com/questions/52569724/), [Maven Shade JavaFX runtime components are missing](https://stackoverflow.com/questions/52653836/), and [Package a non-modular JavaFX application](https://stackoverflow.com/questions/54063041/). – Slaw Jun 19 '20 at 00:50

2 Answers2

3

Take a look at jpackage, a new standard tool in Java 14 for packaging self-contained Java applications. It looks like this is exactly what you need.

Command to build (roughly):

jpackage --name <name here> --input lib --main-jar NameJar.jar --main-class <main class here> --type app-image
ZhekaKozlov
  • 36,558
  • 20
  • 126
  • 155
0

JSmooth - Java Executable Wrapper is a possibility. It is a tool that turns your java applications into .exe files, which is one way to do it. If you want to have an executable .jar file then check the accepted (ticked) answer to this post out How to make an executable jar file? This is the 2 ways I know and both of them work. However, JSmooth is easier and more straightforward if you are fine with the final file being a .exe