0

I have a JavaFX Project, which I want to export as a dmg and exe. The export as a dmg file for Mac was no problem. But the export as a .exe file for Windows is not working. I created a jar file and I ran jlink. Then I exported the project with jpackage. Here is the command:

/path/to/jpackage \
--input %PATH_TO_SDK%/lib/  \
--name "My Project" \
--main-jar /path/to/jar.jar \
--main-class com.company.project.Main \
--type exe \
--add-modules javafx.controls,javafx.fxml,javafx.graphics \
--module-path %PATH_TO_SDK%/lib/

On my machine, it is working perfect, but on others (I tested it on two more machines (they do not have Java(FX) installed)) the CMD window crashes instantly.

GregGott
  • 95
  • 9
  • What if you get rid of the `--input %PATH_TO_SDK%/lib` bit? Also, if that doesn't work, you can try making it a console application (I think the command is something like `--win-console`), run the EXE from the command line, and look at the error output (you may have to tell the terminal to wait, depending on how exactly you launch the program; e.g., with PowerShell, you could use `-NoNewWindow -Wait`). What is the error? – Slaw Apr 24 '22 at 18:21
  • Now it is not running on my machine as well. I can see a small window (i think not a cmd) for less than a second. When I get rid of the `--input` I get `Error: Missing argument: --input or --app-image`. No error in PowerShell. – GregGott Apr 24 '22 at 19:06
  • Try running directly from the jlink’d image tree, instead of the packaged .exe. The image tree will have a command-line executable in its ‘bin’ directory. – VGR Apr 24 '22 at 21:22
  • Yes. The ‘Launcher.bat‘ is working on every machine without any error. – GregGott Apr 25 '22 at 05:48
  • Ok. Finally some progress. Now I can start the application. But I get this error: "Child process exited with code 1". The reason because it crashed yesterday is because I used the IntelliJ Java libs... – GregGott Apr 25 '22 at 16:23
  • Yes. Finally output in the terminal `java.lang.ClassNotFoundException: com.example.demo.HelloApplication`. That is interesting, baucause the path to the class is correct. – GregGott Apr 25 '22 at 16:31
  • That does not match the main class name in your question. – jewelsea Apr 25 '22 at 17:25
  • I created a new demo Project for testing. But also this error I was able to solve. Now I have this one (Jeez): `Graphics Device initialization failed for : d3d, sw Error initializing QuantumRenderer: no suitable pipeline found` – GregGott Apr 25 '22 at 18:46
  • So, there was a problem with jmods. But now I have the same issue like at the beginning. It is working on my machine. And on others I only see 'ClassNotFoundException'. – GregGott Apr 25 '22 at 19:03
  • I don’t know what your exact issue is, bug you could see this question on [JavaFX exe files](https://stackoverflow.com/questions/69811401/how-to-create-a-standalone-exe-in-java-that-runs-without-an-installer-and-a-jr), specifically the part mentioning the ackman jpackage plugin, though to adapt your project to use it will take some work fir you. Also see [package info in the JavaFX tag like JPackageScriptFX. – jewelsea Apr 25 '22 at 20:14
  • All this stuff is only working on my computer on one account. I created a new user on my mac, even the new user can't open the dmg :-( (I have the problem on Mac as well). Thanks for all your support! – GregGott Apr 26 '22 at 15:58

1 Answers1

0

After a lot of research, I found a GitHub repo which shows how to create dmg and exe files. Maven jPackage Template

GregGott
  • 95
  • 9
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 27 '22 at 07:03