r/java • u/kedarjoshi • Mar 19 '19
Java 12 Released !!!
https://www.oracle.com/technetwork/java/javase/downloads/jdk12-downloads-5295953.html51
u/pron98 Mar 19 '19
That download page is for Oracle's commercial Java SE subscription customers. Here's the free JDK from Oracle.
1
78
u/MasterLJ Mar 19 '19
...and here I am still Java 8ing =|
29
u/Life_is_a_meme Mar 19 '19
I don't even know how to migrate to Java 9 and they're already on Java 12...
77
u/MasterLJ Mar 19 '19
Step 1 : Download the Java 9 JRE
Step 2 : Try to run your existing app
Step 3 : Tears
Step 4 : Use the Java 8 JRE
29
u/_INTER_ Mar 19 '19 edited Mar 20 '19
Java 9 is EOL
There's no JRE for Java 11+ (you're supposed to build a runtime that fits your application using jdeps / jlink)
11
u/thedomham Mar 20 '19
There's no JRE for Java 11+
For everyone who was as confused upon reading this statement as me: it's true. There is no JRE anymore. The JRE is practically a subset of the JDK and with jigsaw you are supposed to use the new Java linker (jlink) to bundle an application-specific runtime with your jar instead of relying on a complete runtime (JRE) being available in your target environment.
I initially thought "there is no JRE" was some part of the Oracle license change fearmongering '
2
19
3
u/duheee Mar 19 '19
Step 5: ????
Step 6: Profit!!!!!
1
8
u/MMPride Mar 20 '19
I've migrated all my apps to Java 11, or at least, my ones that will be migrated to Java 11. It's quite... interesting, to say the least. It ranges from easy to very hard depending on what your app uses in terms of dependencies, etc.
5
u/KamiKagutsuchi Mar 19 '19 edited Mar 19 '19
For java 9 most likely all you have to do is add
--add-module java.xml.bindwhen running the program if you use xml (or most json) parsing libraries. Otherwise you dont have to do anything.For java 10+ you have to get replacement libraries for the crap (including xml binding) that has been removed from the jdk. Most likely you don't need any of these libraries, except maybe xml binding.
5
u/MMPride Mar 20 '19
Well, you have to add a lot of modules if you're using JavaFX, like, 250 characters worth of modules... other than that, upgrading to Java 11 is mostly okay depending on what dependencies your app uses.
I gotta admit, the add-module shit isn't quite as nice as just
java -jar app.jar.4
u/KamiKagutsuchi Mar 20 '19
Or just include a dependency on openjfx 11?
2
u/MMPride Mar 20 '19
If the jar is built with Java 9+ support in mind, yeah. If the jar is no longer maintained and you are stuck with a version that doesn't have module support built in? Well, then you may need hundreds of characters instead of just
java -jar app.jar.2
u/endeavourl Mar 20 '19
Isn't is supposed to add them automatically when the jar is also a module that declares it's module dependencies?
1
u/MMPride Mar 20 '19
If the jar is built with Java 9+ support in mind, yeah. If the jar is no longer maintained and you are stuck with a version that doesn't have module support built in? Well, then you may need hundreds of characters for adding modules instead of just
java -jar app.jar.1
u/dpash Mar 19 '19
You can also add the maven/gradle dependency for java.xml.bind API. In some cases you might also need an implementation of the API, but that's just a dependency away too.
4
u/BoyRobot777 Mar 19 '19
I would advice to get "Java 9 Modularity" book. For me, it made a lot of things clear. They also have migration chapter, where they migrate Spring/Hibernate application. Also, a chapter on Maven.
13
u/RotaryJihad Mar 19 '19
You and me both.
15
u/MasterLJ Mar 19 '19
Modules just seem like unnecessary hassle if you already partition your dependencies well, but I'm probably missing some useful use cases. I'm a solo developer, fwiw.
10
u/ObscureCulturalMeme Mar 19 '19 edited Mar 19 '19
Modules seem to be all the rage for enterprise container "app servers" and the like, but for the rest of us, modules are solving a problem that we simply don't have.
Unfortunately, a lot of third party libraries are still problematic to use in 9+, and the JVM unconditionally spits out warnings about them anyhow. So our users complain to us about problems (but not really) in code that we don't control.
4
u/capitol_ Mar 19 '19
It's often very easy to add a Automatic-Module-Name entry to the manifest file, and I have only had one maintainer that have been negative to it when I have opened bug in projects.
2
u/FoodComputer Mar 19 '19
Is this why I see warnings like "found module-info.java. shading will break its strong encapsulation." when using the Maven Shade Plugin?
2
u/MMPride Mar 20 '19
Illegal reflective access warnings are going to be a fun one to fix for unmaintained dependencies when the warnings turn to errors then turn to removals.
3
u/dpash Mar 19 '19
Modules are particularly useful for libraries. It means they can expose their interfaces and public API and completely hide their implementation and private classes without someone using a non-public API. And now your non-public API has hundreds and thousands of users and it's de facto a public API that you can't change.
Don't think people won't use a non-public API they find in your jar? Look at how many people used
sun.misc.Unsafedespite compiler warnings telling them to keep out of anything in thesunpackage.1
u/sievebrain Mar 20 '19
Well not really. Users will just put your JAR on the classpath, or use reflection. They aren't going to not use internal APIs just because they're labelled as such and the compiler tries to make life hard.
1
17
Mar 19 '19
[removed] — view removed comment
12
u/cogman10 Mar 19 '19
Not only that, you get startup time bonuses as well since there aren't as many internal classes to load. For example, your server probably doesn't need to bring in the swing modules.
4
6
2
u/raja777m Mar 19 '19
We have companies stuck with code written in 1.5, but upgraded for the same of security to 1.8..!
2
2
23
u/TrainingDisk Mar 19 '19
Interestingly, JVM boot seems a bit faster. Not that that really matters to most...
$ for j in {5..12}; do . chjdk $j; time (java -version; for i in {1..1000}; do java x >/dev/null; done); echo ""; done
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_22-b03, mixed mode)
real 2m4.988s
user 0m59.832s
sys 0m18.856s
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
real 0m28.055s
user 0m24.012s
sys 0m4.216s
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
real 0m31.225s
user 0m24.836s
sys 0m3.564s
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
real 0m43.463s
user 0m35.948s
sys 0m6.516s
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
real 1m29.909s
user 1m37.892s
sys 0m12.972s
java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
real 1m21.161s
user 1m24.412s
sys 0m13.044s
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
real 0m56.932s
user 1m8.892s
sys 0m9.516s
openjdk version "12" 2019-03-19
OpenJDK Runtime Environment (build 12+33)
OpenJDK 64-Bit Server VM (build 12+33, mixed mode, sharing)
real 0m39.930s
user 0m38.876s
sys 0m9.520s2
u/__helix__ Mar 20 '19
Got to wonder if that is true for the current versions of 1.6 and 1.7. They shipped the final (Oracle) build of 6u211 in December and I believe JDK 7 was 7u211 in January. (Assuming you have an extended support contract and can get the patched versions) . Will try that in a VM tomorrow since you were kind enough to include your test.
1
7
u/catmewo Mar 20 '19
Is there anything interesting in the new version, everybody? (I'm using OpenJDK 8, poor me...)
5
u/bmrobin Mar 20 '19
there's an interesting new
switchexpression. you can write the same switch/case for assignment or return values, only more concisely and as an expression5
u/dpash Mar 20 '19
Although it's not enabled by default. You need a command line argument for both
javacandjava.2
20
8
u/Chaoslab Mar 19 '19
Just got onto Java 11 two months ago. Sheesh.
18
u/pron98 Mar 19 '19
If you're already on 11, upgrading to 12 should be about as easy as the old 6-monthly upgrades (e.g. 8u20->8u40).
1
u/Chaoslab Mar 19 '19
Sweet. Just downloaded it. Wish me luck! (I am sure it will be fine).
12
u/TheCountRushmore Mar 19 '19
Unless you are planning on upgrading every 6 months you should probably hang out on Java 11 until Java 17 comes around.
6
u/pron98 Mar 19 '19 edited Mar 19 '19
Even if you hang on to 11 you must upgrade at least every six months. In fact, you have to upgrade every six months even if you're on 8. The difference is that the nature of the upgrades is somewhat different. The feature releases (11, 12, etc.) are somewhere between the old "limited update" releases and the old major releases, but closer to the former (10 and 11 were about the same size as 8u20 and 8u40). The patch releases are much smaller than the old update releases, and similar to the old patches. The choice is then between two upgrade models, neither of which is particularly similar to the situation before 9: you choose between a gradual process, much more gradual than the old model, of upgrading to feature releases, and a step-wise process, less gradual than the old model, if you stay with the LTS releases.
The great news is that you don't have to choose right away. You can upgrade to 12, etc., and if you see that the gradual process is not for you, you can go back to an LTS.
Also, Oracle is free to offer LTS for any feature release based on customer demand. If a popular feature lands in, say, 14, and there's sufficient demand for LTS for that version, Oracle may offer LTS for 14.
2
u/MMPride Mar 20 '19
That sounds kind of... unorganized and chaotic? Probably not the best way to be maintaining and supporting one of the worlds most popular programming languages...
1
u/pron98 Mar 20 '19
Which part do you find chaotic? The open source project has regular releases, and the commercial entity provides a support service for versions on a regular basis, plus possibly more if their customers demand it.
2
u/MMPride Mar 20 '19
LTS releases should be planned in terms of support, upgradbility, longevity, etc. The fact that they allow any version to potentially be an LTS version sounds cool in theory but in practice it means they don't plan far enough ahead to know which versions will be LTS or not.
2
u/pron98 Mar 20 '19
LTS versions are certainly planned: one every 3 years = 6 releases. So 11 is LTS and 17 will be as well. But if customers demand another product in addition which they can provide, why would they say no?
1
u/Chaoslab Mar 19 '19
The VJ application I am writing in java (Chaoslab) can run on all the way back to Java 6 at this point.
8
u/dpash Mar 19 '19
Top tip, if you have a CI server, run a nightly build against the early access JDK releases (in addition to your regularly scheduled
programmingbuilds). This is particularly easy if you use Docker to build your projects, as there's docker images of Java 13 up already and there's no manual JDK installation required.That way you can get advanced warning of any problems with the upcoming releases.
1
4
u/MMPride Mar 20 '19
I just finished upgrading most of my apps to Java 11 a couple months ago (at least, the ones that can be upgraded to Java 11 currently, some are blocked by undermaintained dependencies) and I think I'm going to be done upgrading for a while. It's not really fun, and most of the time it doesn't really feel worth it. I'll see you guys at the next LTS release.
5
u/gas3872 Mar 19 '19
What is all this thing with previous versions only being available from openjdk? Also it was like java 8 and then suddenly time started moving like 100x faster.
9
u/lbkulinski Mar 19 '19
The platform moved to a new release cadence. There will be a new release every six months. You can read about it here.
3
Mar 19 '19 edited Mar 20 '19
One day Oracle woke up and found out that Kotlin stole Android. Moreover, Kotlin was catching up in the Enterprise world as well and poaching developers at the speed of light.
That day few engineers at Oracle had to clear their desk, shut down freecell and dust off their keyboards...
2
Mar 21 '19
Yeah it seems like Kotlin really kicked their ass in to gear and I couldn't be enjoying it any better. Modern Java doesnt feel as bad to write as old Java, though I still use Kotlin for all non work things (work team uses Java, I dont want to be the new guy making big (not as big as they are making it out to be) decisions and getting fired lol) because it's simply easier to write and read to me.
2
0
u/__konrad Mar 19 '19 edited Mar 19 '19
No GA on https://jdk.java.net/12/ yet
2
u/kedarjoshi Mar 19 '19
Now it has been updated to GA ..
1
u/__konrad Mar 19 '19
Thanks. Technically it's identical with RC (same sha256) ;)
3
u/kedarjoshi Mar 20 '19 edited Mar 20 '19
Yes, last RC build essentially gets promoted to GA. This avoids untested build being released and last minute surprises that might come with it.
As per Mark Reinhold (stated here),
We’ve identified no P1 bugs since we promoted build 33 over three weeks ago so that’s the official GA release, ready for production use.
They adopted this practice for JDK 11 as well. Minor patch release might follow the GA build soon if at all there are non-critical fixes.
1
1
0
u/jodastephen Mar 21 '19
Your regular reminder that you probably don't want to update to Java 12. Stick with Java 8 or 11 (the LTS releases), and get the security patches from someone other than Oracle (AdoptOpenJDK, Amazon Corretto, your distro etc). https://blog.joda.org/2018/10/adopt-java-12-or-stick-on-11.html
0
0
u/Senator_Ahn Mar 20 '19
Just a question, what happened to var replacing primitive types? Ex) var ten = 10 var str = "string"
5
u/PriorProfile Mar 20 '19
Local variable type inference. Added in java 10. It’s not just primitive types.
var strings = new ArrayList<String>();You can do it for any local variable where the type can be inferred.
3
0
u/nqzero Mar 20 '19
has anyone seen a summary of changes to unsafe or reflection ? at the beginning of the cycle there was a lot of pressure to tighten the reigns, but that enthusiasm seems to have mellowed
-10
-12
110
u/4ipp Mar 19 '19
Looks like the popular interview question about differences between final, finalize and finally is going to die.