0

I am a complete newbie when it comes to the finer points of java packaging.

I have written a TCP Data Server using Java-15 via jdk-15 that works quite happily when running under VSCode.

I want to distribute it as MRS_Server.exe hopefully without java needing to be loaded on the host machine nor having to distribute my code.

I have managed to run Jpackage with the following commands:-

jpackage --type app-image --name MRS_Server --input C:\Users\steve\Documents\workspace1_neon\Pi_Server --main-jar C:\Users\steve\Documents\workspace1_neon\Pi_Server\Pi_Server.jar

jpackage --type exe --app-image MRS_Server --name MRS_Server

Which produces MRS_Server-1.0.exe. Which, in turn, creates the folder C:\Program Files\MRS_Server which includes copies of my code in the MRS_Server\app folder, a MRS_Server\runtime folder which I assume contains all files required to run the server, and files MRS_Server.exe and MRS_Server.ico.

At this point I run C:\Program Files\MRS_Server\MRS_Server.exe ... nothing happens!?? I have run it on a machine without and security programs and added to the windows firewall. It should open a window and await traffic but nothing? The program is not displayed in the task manager.

What am I missing? I would rather not have to rewrite the server in another language.

Steve Hall

Milk Round
  • 97
  • 7

2 Answers2

1

Turn on --win-console to see the actual error messages from your application - more info here. Note that jpackage -add-launcher for making versions with/without console does not work in JDK15, but is fine if you use JDK14 or JDK16 Early Access so you will have to re-build without --win-console later if not needing it permanently.

Also use --app-version to ensure that the installation of your second release wipes the first release - more info here.

DuncG
  • 12,137
  • 2
  • 21
  • 33
  • Tried again with suggested changes this time got:- – Milk Round Dec 21 '20 at 15:03
  • jpackage --type app-image --name MRS_Server --input C:\Users\steve\Documents\workspace1_neon\Pi_Server --main-jar C:\Users\steve\Documents\workspace1_neon\Pi_Server\Pi_Server.jar --win-console --verbose Using java48.ico (add MRS_Server.ico to the resource-dir to customize). Warning: Windows Defender may prevent jpackage from functioning. If there is an issue, it can be addressed by either disabling realtime monitoring, or adding an exclusion for the directory "C:\Users\steve\AppData\Local\Temp\jdk.incubator.jpackage8659344422105005200". Succeeded in building Win Application Image package – Milk Round Dec 21 '20 at 15:16
  • However on running the installer on both machines with/without norton 360 the folder empty folder C:\Program Files\MRS_Server is created. – Milk Round Dec 21 '20 at 15:18
  • The system without Nortonhad Java.lang.Unsupported.ClassVersionError 59.65535 try running with '--enable-preview' This machine has Java 8 installed. – Milk Round Dec 21 '20 at 15:26
  • Just changed JAVA_HOME on this machine and still got error. Surely the point of jpackage is not to have to load java? – Milk Round Dec 21 '20 at 16:05
  • Uninstalled java still get 59.65535 error. – Milk Round Dec 21 '20 at 16:11
  • Perhaps as you have built your release with `javac --enable-preview` you need jpackage with `--java-options "--enable-preview"` so that the new runtime will handle the preview code – DuncG Dec 21 '20 at 16:18
  • Also check that your release has it own valid java: `C:\Program Files\MRS_Server\runtime\bin\java -version`. If not use jlink to build a cutdown JRE and use jpackage `--runtime-image` – DuncG Dec 21 '20 at 16:28
0

I abandoned JDK-15 and am using AdoptOpenJDK-16 and am having no problems. Thanks to all who reponded.

Steve

Milk Round
  • 97
  • 7