Questions tagged [java-9]

Use this tag for questions specific to Java 9, which is version 9 of the Java platform, released on the 21st of September 2017. In most cases you should also specify the java tag.

Oracle has released its updated list of proposed or targeted Java 9 enhancements. In addition to previously confirmed Java modularity updates, the most recent list includes a common logging system for all JVM components (JEP 158), more HotSpot JIT compiler controls (JEP 158), and refinements to improve the efficiency of garbage collection (JEP 214), and repair issues introduced by Project Coin language updates in JDK 7 (JEP 213). This is also the first release under the new version-string schema (JEP 223) and will hence be officially be numbered 9, not "1.9.0" as was the case for earlier versions.

Even with delays, Oracle has been steadily moving forward with its plans to modularize the JDK. But the scope of Java modularity took a step up in September, when Oracle announced four new JEPs, including JEP 220: Modular Run-Time Images. Ben Evans, writing for InfoQ, noted that swapping JARs for modules is the "point of no return for modularity," with serious implications for IDEs, toolmakers, and many Java application frameworks:

After this point, The Java Runtime Environment (JRE) will no longer be contained in jar files, and instead will be composed of modules (JSR 376). Files such as rt.jar and tools.jar no longer exist in the JRE. The platform will continue to accept and run applications and libraries packaged in conventional jar files, modular jar files, or in the new module file format. The intention is that over time, application developers wil migrate to the new modular formats as well.

See "Oracle Commit to Java Modularity" for more from Ben Evans on modularity updates in Java 9. Also see Takipi Blog: "Java 9 – The Ultimate Feature List" for a comprehensive (as of November 20, 2014) description of new features accepted or proposed for the next major release of Java, and "What's New in Java 9? (Besides Modules)" for another more recent compilation of features.

The API documentation of the release can be accessed at Oracle's technetwork.

1606 questions
33
votes
3 answers

What is the difference between modules and JAR files?

I am learning about Java 9 from What's New in Java9 and one of the hot topics in the discussion is The Modular JDK. Are JAR files modules? How is a module different from a JAR file?
Neeraj Jain
  • 7,643
  • 6
  • 34
  • 62
32
votes
5 answers

JAXB not available on Tomcat 9 and Java 9/10

TLDR: On Java 9/10, a web app in Tomcat has no access to JAXB even though its reference implementation is present on the class path. Edit: No, this is not a duplicate of How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in…
Nicolai Parlog
  • 47,972
  • 24
  • 125
  • 255
32
votes
2 answers

Create Java runtime image on one platform for another using Jlink

I created runtime image using jlink on my Linux machine. And I see linux folder under the include folder. Does it mean that I can use this runtime image only for Linux platform? If yes, are there any ways to create runtime images on one platform for…
32
votes
2 answers

Is it possible to mix --class-path and --module-path in javac (JDK 9)?

When I compile a module that depends on other modules I've compiled previously I have to specify the --module-path option. This makes modules I depend on visible. But at the same time I would also like to make some non-modular Jar files…
malloc4k
  • 1,742
  • 3
  • 22
  • 22
31
votes
1 answer

Why is the finalize() method deprecated in Java 9?

(This question is different from Why would you ever implement finalize()? This question is about deprecation from the Java platform, and the other question is about whether one should use this mechanism in applications.) Why is the finalize() method…
J.J. Beam
  • 2,612
  • 2
  • 26
  • 55
31
votes
2 answers

Error compiling in IntelliJ IDEA: "No MessageCollector"

Edit: Solved. See @acdsee's comment to see how. Since I updated IntelliJ IDEA from 2017.3.5 to 2018.1, every project I start throws this error: > Error:Module 'JBA' production: java.lang.Exception: LOGGING: Loading > modules: [java.se, javafx.base,…
Samplasion
  • 527
  • 4
  • 17
31
votes
4 answers

How to execute a java script with jshell?

Given that Java 9 is upon us and we can finally have a java REPL with jshell I was hoping there was a way to add a shebang to a script and have jshell interpret it. I tried creating test.jsh: #!/usr/bin/env jshell -s System.out.println("Hello…
steinybot
  • 5,491
  • 6
  • 37
  • 55
31
votes
3 answers

Package conflicts with automatic modules in Java 9

With Java 9 on the close horizon I thought it would be a good learning exercise to port some of my projects over to Java 9. In one of my projects I have dependencies for rxjava and rxjavafx dependencies { compile 'io.reactivex:rxjava:1.2.6' …
flakes
  • 21,558
  • 8
  • 41
  • 88
30
votes
3 answers

Why are Optional's or and flatMap methods' supplier type parameters wildcards?

The Optional.or method was added in Java 9. This is the method signature public Optional or​(Supplier> supplier) Why is the type parameter of the Supplier taking ? extends Optional rather than just Optional, since…
Thiyagu
  • 17,362
  • 5
  • 42
  • 79
30
votes
4 answers

Unrecognized VM option 'MaxPermSize=512m' when running Zeppelin

When I try to run Zeppelin by either bin/zeppelin.sh or bin/zeppelin-deamon.sh start I was getting the following error message. Unrecognized VM option 'MaxPermSize=512m' Error: Could not create the Java Virtual Machine. Error: A fatal exception…
sbbs
  • 1,450
  • 2
  • 13
  • 20
30
votes
1 answer

--add-modules only on compilation

I'm building my project with maven and java-9. I've added in my pom.xml file: maven-compiler-plugin ${maven-compiler-plugin.version}
wbk
  • 1,310
  • 2
  • 11
  • 19
29
votes
4 answers

Replacing finalize() in Java

Object.finalize() is deprecated in Java 9, and I think I understand the reasons why, but I'm having trouble seeing how to replace it. I have a utility class called Configuration which essentially has a single instance that owns everything in the…
Michael Kay
  • 156,231
  • 11
  • 92
  • 164
29
votes
2 answers

Properly set up Java 9 as SDK in Intellij IDEA on Linux due to new folder structure

Before you write me off, please consider that neither of these are answers to my question: How to setup SDK in IntelliJ IDEA? How do I change the IntelliJ IDEA default JDK? In IntelliJ IDEA 2017.2.6, attempting to add JDK9 as an SDK passes but…
anon2234
  • 291
  • 3
  • 4
28
votes
4 answers

Since Java 9 HashMap.computeIfAbsent() throws ConcurrentModificationException on attempt to memoize recursive function results

Today I learned from some JS course what memoization is and tried to implement it in Java. I had a simple recursive function to evaluate n-th Fibonacci number: long fib(long n) { if (n < 2) { return n; } return fib(n - 1) +…
Kirill
  • 6,762
  • 4
  • 51
  • 81
28
votes
9 answers

IntelliJ IDEA Ultimate 2018.3 thinks my Java 9 Project is a Kotlin Project

I have an IntelliJ project composing several subprojects which are all Java 9 modules. I use Maven as a build system. My project has no "Facets". My run configuration looks like this: My project settings look like this: I can build everything with…
dax
  • 591
  • 2
  • 6
  • 16