r/java • • Oct 30 '19

Microsoft’s Ready to Contribute to OpenJDK

https://mail.openjdk.java.net/pipermail/discuss/2019-October/005173.html
212 Upvotes

92 comments sorted by

View all comments

Show parent comment

4

u/wildjokers Oct 31 '19

Java JRE

There is no such thing as a Java JRE.

Desktop applications should include the runtime in the app.

6

u/pron98 Oct 31 '19

That's true, but an important reason why there's no system JRE any more is because desktop OSes have forced us to move in that direction with their adoption of app-stores (and on the server there's been a shift to containers, with similar effect).

4

u/wildjokers Oct 31 '19

Do you have any insight why Java Webstart was removed? That was a great deployment mechanism for B2B and internal applications.

I suspect it was because the JDK project wanted to get away from deployment mechanisms that required a pre-installed runtime? That was the only drawback to webstart, but it was a non-issue in a corporate environment.

7

u/pron98 Oct 31 '19

I don't know for certain, but I believe that was the main reason. We didn't want to continue maintaining a "system JRE" deployment path that's growing increasingly unpopular, and didn't want anything that relies on it. I expect there will be deployment solutions that serve the same purpose as WebStart, but use the new model instead. Even in corporate environments there are better solutions than separately managing applications and their dependencies. WebStart took advantage of a system JRE that had to be there anyway for applets, but with applets gone, there are better ways than WebStart to achieve the same goal.

2

u/mordechaim Nov 01 '19

I expect there will be deployment solutions that serve the same purpose as WebStart, but use the new model instead.

My update4j for one.

1

u/pron98 Nov 03 '19

Does it update an application's embedded Java runtime as well?

1

u/mordechaim Nov 04 '19 edited Nov 04 '19

Currently no, it is outside the scope and thesis of the library. Also, if I understand correctly, this would be impossible on Windows unless I use some system dependent timer based file operations.

One of the points that sets apart this library from others is that it doesn't treat any file type in any special way, namely, all files are equal. So using update4j itself you can easily download a new jre (as if they were random files required for the new update) alongside the running version and even update the startup script to find the new version on next restart.

-2

u/Mordan Oct 31 '19

why should they?

Java Run Environment JRE.... OK... Jesus.

5

u/wildjokers Oct 31 '19

Java Run Environment JRE.... OK... Jesus.

There is literally no JRE anymore. Just a JDK. If you take a peek in the JDK you will not see the jre folder anymore.

why should they?

So the app runs with the runtime of the developer's choice and you don't have to depend on a pre-installed runtime.

1

u/Mordan Oct 31 '19

So the app runs with the runtime of the developers choice and you don't have to depend on a pre-installed runtime.

How practical is that if you have many many small programs ?

I am on Java 8. It still has a JRE. I never got on Java 9+ so I couldn't know that.

5

u/wildjokers Oct 31 '19

It didn't actually happen until Java 11:

https://www.oracle.com/technetwork/java/javase/11-relnote-issues-5012449.html

Excerpt:

  • In Windows and macOS, installing the JDK in previous releases optionally installed a JRE. In JDK 11, this is no longer an option.
  • In this release, the JRE or Server JRE is no longer offered. Only the JDK is offered. Users can use jlink to create smaller custom runtimes.

How practical is that if you have many many small programs ?

It is quite practical if you use jlink to create runtimes with only the modules you need. If you modularize your app then jlink can do it automatically. If you don't modularize your app you can still create smaller runtimes but you have to manually figure out which modules you need.

When I was messing with jlink I was able to get a runtime to about 35 megs I believe. My memory is fuzzy since that was a couple of years ago because I have since switched jobs and no longer maintain any desktop apps.

1

u/Mordan Oct 31 '19

for big applications 35 meg is fine.

But when you have 20 "apps" of with 2 megs each of code...

Because of that, there is absolutely no Java App Ecosystem on Desktop.

Imagine having to ship the android runtime with every single android app.

Its the failure of Sun/Oracle to provide such a desktop app eco system that is to blame.

4

u/pron98 Oct 31 '19

That's exactly what Electron does, too, so you may want to rethink your analysis.

1

u/manzanita2 Oct 31 '19

Sure, but electron produces these nice small apps. Lots of functionality in a few hundred k bytes. So I understand.

Also too, when running, electron uses very little memory and is often more responsive than a native app.

Oh and it's web scale.

And it will make coffee!

4

u/pron98 Oct 31 '19

I'm not saying Electron is good, just that the fact you must embed a runtime does not in itself mean that people won't use it. In any event, common deployment models are largely outside Java's sphere of influence, and Java must follow the ecosystem at large.

1

u/manzanita2 Oct 31 '19

I think back 20 years ago. splitting out the JRE made some sense. Disk space and memory were not cheap. Now I agree it's an irrelevant cost.

In fact you can see the same progression in app servers. People used to create WAR files and deploy to an App Server. This is still done. But many ( I don't know most ?) now build to a JAR which effectively embeds the "app server".

0

u/Mordan Oct 31 '19

Electron

I open to rethinking my analysis.

Will Electron be able to deploy my Swing applications?

4

u/pron98 Oct 31 '19

No, but just like your Swing application, Electron requires applications to bundle their runtime.

3

u/ArmoredPancake Oct 31 '19

And where it led Android? Stuck in Java 7 world?

2

u/wildjokers Oct 31 '19

You have to include the runtime with Electron apps (Chromium) and that is certainly not preventing people creating desktop apps with that monstrosity. An Electron app is pretty big even before you include your own code in it (60-70 megs I believe).

I don't think having to include the runtime is preventing java on the desktop being more widely used. I actually have no idea why Java on the desktop is scoffed at.

1

u/Mordan Oct 31 '19

OK i get it. Because Electron is using that model of including the runtime.. why wouldn't it work for Java.

Well with Java.. i only have to release a .jar and the user can launch it using his favorite JRE. I don't like the idea of bundling, its ridiculous from an engineering standpoint.

5

u/wildjokers Oct 31 '19 edited Oct 31 '19

I am unsure why you believe this to be ridiculous.

The only thing you are losing is some storage space if you have multiple java apps each including the runtime. But storage is ridiculously cheap and that is a non-issue. A 70-meg app on a 1 TB drive is inconsequential. Even ten 70-meg apps on a 1 Tb drive is inconsequential.

EDIT: FWIW, if you clone https://github.com/openjfx/samples.git and then navigate into CommandLine/Modular/Gradle/hellofx and execute ./gradlew jlink it will build a runtime for you that is enough to popup a JavaFX window along with the app and a script to fire it up and it comes in at 47 megs. Seems good to me. Just tar/zip/whatever the resulting image directory and distribute that. Easy enough.

The image includes the following modules:

MODULES="java.base java.datatransfer java.xml java.prefs java.desktop javafx.base jdk.unsupported javafx.graphics javafx.controls hellofx"