2

I am using OpenJDK 11 and OpenJFX 11 on Windows 7. My IDE is Netbeans 9. I have replicated the tutorial (published by NetbeansVideos) below :

JDK 11, OpenJFX, Apache Ant, and Apache NetBeans 10

It is a simple Hello World type code. It works in Netbeans. But when I click the JAR file it doesn't work.

My JAVA_HOME in environment variable is set.

How do I make that Module JAR execute by clicking?

Thanks.

Sova
  • 21
  • 3
  • 1
    Possible duplicate of [Running JAR file on Windows](https://stackoverflow.com/questions/394616/running-jar-file-on-windows) – hpm Nov 07 '18 at 07:00
  • There is no support for executable modular JARs so it will need a script to run the java launcher with the right options. – Alan Bateman Nov 07 '18 at 16:29
  • @AlanBateman I'd suspicion that was the case. I was really hoping that I did something wrong. Reasons are piling up to leave the Java World ! – Sova Nov 07 '18 at 17:16
  • 1
    If you already have a module, you can use `jlink` to create a custom image that you can run, almost like when you ran `java -jar myjar.jar`. In fact NetBeans has support for it. See this [sample](https://github.com/openjfx/samples/tree/master/IDE/NetBeans/Modular/Java). – José Pereda Nov 09 '18 at 21:54
  • Regarding _"I have replicated the tutorial"_, you haven't. The tutorial is using a beta version of NetBeans 10 but you are using NetBeans 9 which does not support Java 11. Switch to the [beta version of NetBeans 10](https://builds.apache.org/job/incubator-netbeans-linux/lastSuccessfulBuild/artifact/nbbuild/) if you want to follow that tutorial. – skomisa Dec 04 '18 at 01:25

1 Answers1

0

An archive becomes a modular JAR when you include a module descriptor, module-info.class, in the root of the given directories or in the root of the .jar archive.

-- https://docs.oracle.com/en/java/javase/17/docs/specs/man/jar.html

If you get your OpenJDK binaries from Adoptium, their installer has an option to associate .jar files. (Not sure about other distros) When you have the file association setup double clicking on a modular, executable, jar file behaves as expected. (Confirmed this is working as of JDK 17 and Windows 10). If not, you can manually setup the Windows file association yourself as described in: Running JAR file on Windows

user1086516
  • 887
  • 3
  • 9
  • 21