

Location of compiled classes in the project To make sure your code isn’t using internal APIs that will be hidden in Java 9, you can use a tool called jdeps.įigure 2 shows where my compiled classes live in my project.įigure 2. In the past, developers were expected to follow guidelines to reduce the risk of depending on an unsupported class in the JDK but it’s much better if a language, framework, or library can hide things that developers shouldn’t use. One of the goals of this release, and surely the most famous Java 9 feature, is to allow the JDK developers to hide internal implementation details. Identify problematic dependencies with jdeps. Note that names containing underscores, for example _fieldName, are still valid the problem is identifier names that contain only an underscore and nothing else.

If you come across identifier names that consist of only a single underscore, you’ll need to rename them. This is because underscores might be used in a later version of Java to make working with lambda expressions even easier. This single-underscore name has been removed as a legal identifier name in Java 9 as part of JDK Enhancement Proposal (JEP) 213. In Figure 1, you can see that the code has a field with a single underscore as a name. Other IDEs, such as NetBeans and Eclipse, will have similar functionality. I’m using my IDE, IntelliJ IDEA, to compile the code and to show me the warnings, but what you see in the messages box in Figure 1 is the same as what you’d see using javac from the command line. Example compiler warning about a potential problem

First, of course, you can look at any compiler warnings, because some of those will tell you about potential problems (see Figure 1).įigure 1. There are several tools available in Java 8 that will give you appropriate hints.Ĭompiler warnings.

You can determine the amount of effort that might be required to migrate to Java 9 without even downloading or using it. You should also look at this detailed migration guide to get a feel for what steps might be needed. I’ll be using this approach throughout this article. So, instead of updating $JAVA_HOME to point to the new installation, you might want to create a new environment variable, $JAVA9_HOME, instead. Until the impact of Java 9 on your system is understood, you probably don’t want it to be the default Java version. At the time of this writing, it is still an Early Access release and can be found here (in this article, I’m using build 9-ea+166). Getting Startedįirst, download and install the latest version of JDK 9. I principally examine what you need to do to get the code compiling and running. This article shows the steps you take to run Java 8 code and use some of the new features of Java 9 without migrating to modules.
