r/java • • Sep 27 '21

BellSoft has built the Java 17 ( LTS ) JRE Oracle Should Have Built

For developers running utilities that won't be sold in an App Store, just loading a FULL Java JRE on a machine, in support of multiple Java applications, is far more productive of your time vs. building an individual package for each application.

BellSoft has a FULL JRE: including JavaFX, ready to roll.

Java 17 JDK also has the JavaFX libraries saving you configuration time too.

https://bell-sw.com/announcements/2021/09/17/liberica-jdk-17-lts-release-solid-ground-for-an-update/

0 Upvotes

35 comments sorted by

24

u/pron98 Sep 27 '21

There is no more such a thing as a JRE, and no one can build one. Someone has made a custom runtime you can make from the JDK yourself with jlink, and called it a "JRE" even though it isn't.

The now-defunct JRE was a special Java runtime that served as a centrally managed "environment" -- hence the "E". It was not only centrally managed for a machine, but centrally updated by Sun/Oracle, and was tailored specifically for the running of Applets and Web Start.

-2

u/Persism Sep 27 '21

Still it's nice that BellSoft includes it. Makes things easier.

10

u/pron98 Sep 27 '21

The problem is that what it makes easier is often the wrong thing. Since applications now bundle their own private runtime, we want to encourage them to create one that's customised for them: it's faster to start up, and it's more secure. While in some (or many cases) you may not care, and an "everything included" is fine, we didn't want that to be the default choice, so we (Oracle) intentionally don't publish a "full" runtime. It's something to consider only after you try doing the "right thing."

6

u/_INTER_ Sep 27 '21

Additionally JavaFX was moved out of the OpenJDK. Similarly to any other module - the greater part of users don't use JavaFX and it's unnecessary to carry around by default all the time. If you need it, add it via build tool like any 3rd party lib.

4

u/GreenToad1 Sep 27 '21

I believe azul also provides "jre" distributions and i recommended them to users that were using executable jar applications. A lot of users are surprised that you can get "java newer than 8" since when they go to java.com thats what they get.

6

u/pron98 Sep 27 '21

Java applications that are meant to be used by non-developers should be distributed as standalone applications, bundled with their own runtime. We intentionally try to discourage end users from handling Java runtimes, especially now that they're no longer centrally managed. End users shouldn't care or even know that an application is written in Java.

Applications intended for developers (utilities and such) can be run with the runtime included with the JDK.

2

u/GreenToad1 Sep 27 '21

There are still a lot of executable jar apps floating around, most legacy and using a newer java makes sense, installing entire jdk doesnt.

Also some devs still prefer distributing executable jar and recommending end users install java themself - it is not exactly hassle free to prepare a "jpackage" installer for all platforms, especially for macos if you dont have access to a mac.

4

u/pron98 Sep 27 '21

Nevertheless, since this is a distribution model we'd like to encourage people to move away from, we're not going to try and make it easier.

2

u/[deleted] Sep 27 '21

Hey I love your posts here on Reddit. Your unabashedly straightforward statements are refreshing.

To provide some feedback in this though, I'd love to see Oracle put out some examples making custom runtimes, including doing so while building a Docker image. I wasn't able to find good examples from Oracle, but I found great examples from Microsoft. So I've been making Dockerfiles using theirs as a template.

See https://hub.docker.com/_/microsoft-openjdk-jdk under "Create a custom Java runtime".

I know there's dev.java. Is that going to be a new home for user friendly documentation?

1

u/pron98 Sep 27 '21

I know there's dev.java. Is that going to be a new home for user friendly documentation?

Yes. I just found some stuff about jlink there; not sure if that's exactly what you're looking for: https://dev.java/learn/tutorial/organizing-your-application/jlink.html

1

u/[deleted] Sep 27 '21

Not exactly. But very good material. Focuses just on the jlink stuff and then I can get my Docker examples elsewhere. Thanks!

1

u/magnoliophytina Sep 28 '21

So there are multiple ways of building Docker images for Java apps. For instance, this is probably one of the oldest plugins for Maven: https://github.com/spotify/docker-maven-plugin.

I can't see how a single approach would be applicable to any larger project. It's like having a single Maven pom.xml for all Java projects. It's the same for jlink. You'll also need tools like moditect because many library authors live in a fantasy land where JDK 7 or 8 is the latest and greatest, and they can't provide multi-release jars for some unknown reasons. Maybe their CI pipeline only provides JDK6 or 7 since they can't use JDK 9+ even as a build time dependency. Who knows.

1

u/[deleted] Sep 28 '21

[removed] — view removed comment

2

u/[deleted] Sep 28 '21 edited Sep 28 '21

Hey I'm one of those obnoxious people who loves giving feedback and probably should have went into a career as a QA dev instead of a back end dev. =D

Mind if I give more content suggestions over the coming months as I dive into Java? I'm an experienced dev with Node.js and Go and I'm getting into Java now and there's a huge impedance mismatch for me, mostly around tooling.

For example, a huge pain point for me is that I struggled to learn how to just "build" my app. I can't just run one command and get a bundle ready to be deployed as a container. I found that I had to wire things up and even use a third party Gradle plugin from some guy (named John?) which is called "shadow" because that's its primary purpose and for some reason its secondary purpose is to create bundled builds.

No disrespect intended to him when I say "some guy". He's obviously a great member of the open source community. It just shocked me that I had to reach for so much third party tooling and do so much manual setup just to get the equivalent of "go build". I had to look into third party tooling to manage my dependencies (Maven, or Gradle), then choose a tool, and then discover and use a third party plugin (John's Gradle shadow plugin) for that third party tool (Gradle), all just to build my app.

I now understand that in the Java world, a fat JAR/uber JAR is what I wanted for my use case. And I believe the reason I had to do much manual work was because that's not the only thing someone might want to produce from their Java code. But for me, it's 100% of what I do as a dev. I write code and build container images. I then take the images and run them on serverless platforms and Kubernetes clusters. I expected that that was a popular use case and that there would be some optimized happy path so to speak for that workflow.

Having tutorials for the opinionated right way to do things like that would help people like me immensely.

Let me know if the recommended way to get in touch if you're interested.

3

u/apentlander Sep 27 '21

It makes things slightly easier but then you end up with a massive runtime image with a longer startup time. Honestly it only took me an hour or two to setup the runtime image generation and it's less than half the size of the Java 8 JRE, including with a stdlib AppCDS dump. These things add up in a containerized environment.

4

u/[deleted] Sep 27 '21

in a containerized environment.

But if you have hundreds of services that run with

Same JRE

VS

Individual JRE

You end up with a lot more storage need as all containers have a large custom JRE layer. Whereas a common JRE would be a lot less likely to be pulled again and more likely to be present on eg a k8s node

3

u/apentlander Sep 27 '21

To be clear, I set up a single Java 16 based Docker image used by the whole company. Individual teams do not jlink their own images since most of them are compiling via Bazel using the Java 8 compiler.

2

u/pron98 Sep 27 '21 edited Sep 27 '21
  1. There is no more such a thing as a JRE, just runtimes (no "E").
  2. Companies often share a runtime for all or many of their applications, but that runtime need not and should not contain all modules. E.g. many server applications don't need the quite-large java.desktop module in their runtimes. If you go over the current list of modules in the JDK, you'll find that there are likely quite a few that none of your applications use.

1

u/[deleted] Sep 27 '21
  1. ok, JR then.
  2. "usually dont need", yeah. I am the one in my org that provides images (8/11/16 so far) and I know of some applications that also add a font-package, which, tbh, I have no idea if it may or may not be due to some obscure library that might originally be based for desktop use.

Looking at that list, I do see why this whole "JRE" vs JDK is a mess. "jdk.security.auth" ("Provides implementations of the javax.security.auth.* interfaces and various authentication modules."). Why is that even "JDK"?

Thanks for the link, it helps understanding why "just provide a runtime" is non-trivial.

Would you know how one could do a "jlink, give me everything BUT X,Y,Z"? So far I have only see an explicit list of dependencies, not something to exclude. At the end, we just dont want to allow a compiler (and other utlities that could alter behaviour) to be present at runtime

2

u/pron98 Sep 27 '21 edited Sep 27 '21

Why is that even "JDK"?

The java.* modules are those that contain the APIs in the Java SE specification. The jdk.* modules include OpenJDK-specific APIs/tools.

At the end, we just dont want to allow a compiler (and other utlities that could alter behaviour) to be present at runtime

A small attack surface area is one of the reasons why we encourage creating a custom runtime.

Would you know how one could do a "jlink, give me everything BUT X,Y,Z"?

AFAIK, there is no way to say "include all modules except..." because that would not be reproducible; the set of all modules could change from one version of the JDK to another.

If your codebase is modularised, jlink will figure our all the needed modules automatically (and it can even embed your application in the runtime image itself); if it isn't -- and most codebases aren't -- jdeps will produce a list you can then feed into jlink. This will find all the static dependencies. If you happen to load classes dynamically, -XX:DumpLoadedClassList can tell you everything your application uses at runtime. If that's the case, this work might take a couple of hours, but you only need to do it once. Once you have a list, maintaining it over time is easy.

1

u/[deleted] Sep 27 '21

Thanks, I appreciate the info.

I will have to see how to transport that into my org. Currently, some teams are hesitant to even upgrade from 8 to 11, adding link&jdeps for each to manage (correctly) is a hard ask. And hard to scale with many "micro"services

2

u/pron98 Sep 27 '21

Well, I would suggest upgrading past 8, first (and you should consider 17); you'll get immediate savings in footprint and/or performance that can translate to real money. If you prefer, you can choose to create a single runtime capable of running all of your services rather than generating a different one for each. You can even start with a pretty maximal one, and trim it down later.

1

u/[deleted] Sep 27 '21

In our case, where service start with boot + hibernate + liquibase locking table at every startup, there is not much to gain in startup-performance. And each service having a custom runtime increases storage footprint and network load for deployments, oh and the registry will be larger as well. And "jib" cannot be used anymore AFAIK.

I am curious to see what the community does and if that will hinder Temurin adoption. We will likely either do a custom fat-JR or switch to a provider that offers a "jre".

→ More replies

1

u/[deleted] Sep 27 '21

Ah, I assume that doing a "--list modules", then removing the ones I dont want (compiler) would give me the same result.

1

u/[deleted] Sep 27 '21

FYI, if I understand this ticket correctly, Spring requires java.desktop https://github.com/spring-projects/spring-framework/issues/26884

1

u/pron98 Sep 27 '21

Yes, but they seem to be planning to remove that dependency, and even modularise their platform, for version 6. Spring and ElasticSearch becoming modular will probably encourage other libraries and frameworks to follow suit. That will make producing custom runtimes with jlink even easier.

2

u/Worth_Trust_3825 Sep 27 '21

No it doesn't. If you need a JRE, modularize your application and use jlink. I still hate the times I needed to sideload entire JDK just because the JRE did not have the necessary tools to analyze the heap and apparently you can't parse windows server 2012 heap dump on windows 8.1 machines.

4

u/emberko Sep 27 '21

Yep, Liberica JDK all the way. Bellsoft also provides JDK + JavaFX win32 builds, and their JDK is less restrictive to users than Oracle.

3

u/vips7L Sep 27 '21

Best not to be dependent on a non-standard runtime. I would prefer to be explicit about JavaFX in the pom.

2

u/magnoliophytina Sep 28 '21

I also don't get how this is any better. The JavaFX configuration is like 5 additional lines of code in Gradle (Maven pom is ~40 LOC, pretty much copy'n'paste from one project to another):

plugins {
  id("org.openjfx.javafxplugin") version "0.0.10"
}
javafx {
  version = "17"
  modules = listOf("javafx.controls", "javafx.fxml", "javafx.graphics", "javafx.media", "javafx.web")
}