Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Problems making an "uber jar" containing a JRE with IntelliJ

  1. #1
    Junior Member
    Join Date
    May 2023
    Posts
    7
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Problems making an "uber jar" containing a JRE with IntelliJ

    * IntelliJ IDEA Ultimate
    * temurin-21.jdk
    * macOS 13.6 Ventura

    I have a Java/Swing app which is running under `temurin-21.jdk`. I usually test it just by running it in IntelliJ. The ultimate aim is to produce an `uber-jar` containing all of the project dependencies, as well as the `temurin-21.jre`, which I have installed and is sitting alongside the `jdk` in `/Library/Java/JavaVirtualMachines/temurin-21.jre`.

    I have experimented with enabling the `build artefacts` and am now able to build a `semi-uber-jar`, as it were, containing my project classes as well as the 3rd party dependencies, and am able to run the app using it.

    In the past, I've used the `Maven Shade` plugin to gather in extra classes into my `uber-jar` but I don't know if this is the right route to follow here. I've a sneaking suspicion that the answer lies in the `Artefacts` dialog, particularly in the highlighted sub-menu...

    Posting attachments isn't working for me (when I click the "Manage Attachments" button, nothing happens) so I've posted the image of the dialog here https://ibb.co/qy4Mcbg

    The ultimate, ultimate aim is to produce a self contained macOS app containing everything necessary to run the app, although I have had more success in this, using a little app which acts as a front end for JPackage, called JarPackager - https://apps.apple.com/gb/app/jarpac...19577577?mt=12, and a macOS DMG builder called DropDMG - https://apps.apple.com/gb/app/dropdmg/id414234859?mt=12

    If someone could give me some guidance on constructing my `uber-jar` containing a JRE, I would be very grateful!

    Thanks in advance!

  2. #2
    Junior Member
    Join Date
    May 2023
    Posts
    7
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Problems making an "uber jar" containing a JRE with IntelliJ

    It seems like the concept of using a JRE has been replaced with using JLink to produce a more tailored set of dependencies. The problem is that, like so many command line Java tools, there are various sources of information about JLink, none of them consistent and none of the up to date. The search continues... 😉

  3. #3
    Junior Member
    Join Date
    May 2023
    Posts
    7
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Problems making an "uber jar" containing a JRE with IntelliJ

    The Java app in question uses Swing and a few other libraries, namely: org.javatuples, org.json and net.byteseek.

    I tried to use `jlink` with `java.base` and `java.desktop` as additional modules. This produced a sub-folder called `jdk-with-swing` which sounded promising. I then used the `+` -> `Extracted Directory` and loaded in the `jrt-fs.jar` file that the `jlink` operation had created. I finally did a `Build` -> `Build Artefacts...` which generated a nice, juicy, fat `JAR` file which appears to run.

    I finally used `Jar Packager` https://apps.apple.com/gb/app/jarpac...19577577?mt=12, and a set of macOS icons to produce a (hopefully) working `.app` file. I've got someone, without Java installed, alpha-testing it for me. He's just let me know that the `.app` file wouldn't open.

    Could someone have a look at the steps I have outlined here and tell if I am on the right path with this approach?

  4. #4
    Member Helium c2's Avatar
    Join Date
    Nov 2023
    Location
    Kekaha, Kaua'i
    Posts
    102
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Problems making an "uber jar" containing a JRE with IntelliJ

    You're already a good programmer. Is there anything that should have been attached to the class files? uber.jar files? Like already known clients maybe. Added to the class files.

Similar Threads

  1. Replies: 1
    Last Post: August 20th, 2019, 07:07 AM
  2. Replies: 4
    Last Post: July 18th, 2014, 02:04 AM
  3. Replies: 1
    Last Post: July 16th, 2014, 04:16 AM
  4. Replies: 2
    Last Post: May 22nd, 2014, 01:17 PM
  5. Problems Making a "POST" to a Socket
    By haroldjclements in forum Java Networking
    Replies: 0
    Last Post: October 11th, 2011, 05:28 AM

Tags for this Thread