1

What I'm trying to do is to build a java swing app that's compatible on both Windows and macOS. Exporting an executable jar file and running it on another computer with JRE on it works perfectly, but the problem lies with computers that don't have it.

I want to have it so my app installs the necessary JRE on the device without the need for redirecting the user to the site to download and having them install it separately. I learned that this could be done through self-contained applications, where the package has the necessary JRE built into it, but the official documentation (https://docs.oracle.com/javase/10/deploy/self-contained-application-packaging.htm#JSDPG583) is way too vague.

From what I've seen, a couple of ways for creating self-contained apps are modifying the Ant Task fx: deploy, and the javapackager -deploy command. I've tried both of these, but I had problems with each. For Ant, it isn't clear where the file(s) containing the attribute is (or how to go about creating it), and for javapackager, this page here:(https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/packager.html) said to add a path to javapackager.jar located in the bin directory of my JDK installation; I've already added %JAVA_HOME%\bin to the path, but that doesn't help since javapackager.jar doesn't exist at all (jre-12 is my installation, if that helps).

I'm new to this sort of thing, so as much detail as possible would be greatly appreciated.

Thanks

Basil Bourque
  • 218,480
  • 72
  • 657
  • 915
  • 3
    As of Java 9 this is a licensing violation. – Elliott Frisch Mar 30 '19 at 23:39
  • 1
    I asked a similar question awhile ago; hopefully it helps: https://stackoverflow.com/questions/46860679/self-contained-applications – Jacob G. Mar 30 '19 at 23:57
  • Yes, `jlink` and `jpackager` are the tools you need. See [JEP 282](https://openjdk.java.net/jeps/282) and [JEP 343](https://openjdk.java.net/jeps/343), as well as [*Java Client Roadmap Update* of 2018-03](https://www.oracle.com/technetwork/java/javase/javaclientroadmapupdate2018mar-4414431.pdf) and [*Java Is Still Free*](https://medium.com/@javachampions/java-is-still-free-c02aef8c9e04). More info available on the [original Question](https://stackoverflow.com/q/46860679/642706) of this duplicate. – Basil Bourque Mar 31 '19 at 00:40
  • As Elliott Frisch commented, the Oracle-branded JDK changed its licensing terms: Deployment is no longer free-of-cost. You may want to obtain a Java implementation from an alternate vendor. See [*How to get java 11 run-time environment working since there is no more jre 11 for download?*](https://stackoverflow.com/q/53111921/642706). Be sure to study the terms of any JVM you obtain. – Basil Bourque Mar 31 '19 at 00:49

0 Answers0