JDK9Support

Revision as of 11:10, 4 October 2016 by Mbalin (Talk | contribs)

Contents

JDK9 EA Support

NetBeans IDE previews early experimental support for JDK 9 EA development builds including project Jigsaw, the new modular system for Java. The NetBeans team is providing this as a preview of development work done in NetBeans IDE with the goal to have comprehensive support of JDK9 with modules (Jigsaw project) at the time of release of JDK 9. Features are not complete, at this stage, and WILL break in the future. JDK 9 and the Jigsaw project are also moving targets, which have not reached Feature Complete status yet.

The work started for Java SE support and projects (NB Ant project). Other areas like Java EE or Maven are not being worked on for JDK9 EA at this time. Later when Java SE support will be in desired state NetBeans developers of all other modules should start to use this for their work on making other NB modules to support JDK 9 EA and module system.

Sources and builds are available on AS IS basis without any warranty and testing. Bugs could be filled for JDK 9 EA support into bugzilla with Keyword JDK_9.

Features and UI is still being designed and will change. Don't use these builds for real work! A lot of exceptions ...

NetBeans JDK9 support development is done in jet-main repository on a branch jdk9. Daily builds are available at http://bits.netbeans.org/netbeans/nb9-for-jdk9_jigsaw/daily/latest/ this is Java SE distro only.

Regular NetBeans Development builds (planned NetBeans 8.2 release) does not fully support JDK 9 and module system.

Getting Started

  1. The NetBeans JDK 9 build runs on top of Java SE 8, you can download the latest update of Java SE 8 here. JDK 7 and older is not supported by NetBeans after NetBeans 8.1 release.
  2. Download the latest JDK 9 Early Access from https://jdk9.java.net/download/ page
  3. Download NB JDK 9 dev build from http://bits.netbeans.org/netbeans/nb9-for-jdk9_jigsaw/daily/latest/ or build it from sources.
    1. In some operating systems NetBeans, by default, launches on the most current JDK version available. Installing JDK 9 EA might cause the NB JDK 9 branch build, as well as other versions of Netbeans, to run with JDK 9. Although it is is possible to run the NB JDK 9 branch on JDK 9 (see below for instructions), you should consider configuring NetBeans (every version installed) to launch with JDK 8 (see Changing NetBeans JDK runtime platform below for instructions)
  4. Register the latest JDK 9 EA build as a Java Platform in NetBeans JDK9 build by means of Tools | Java Platforms | Add Platform.

What works

NetBeans JDK 9 builds support:

  • NB Java SE project support one JDK9/Jigsaw module - Single module project.
  • module-info.java support: editing works and using its statement to set module boundaries for projects
  • All Editing features work according to what is declared in module-info.java
  • Using other NB Java SE Single module projects as libraries (project dependency) is possible
  • Compilation works
  • Run & Debug projects work
  • Unit tests can be compiled and run.
  • All other features unrelated to Java language like SCM should work.

What DOES NOT work

  • Multiple JDK9 modules in one NB project
  • Maven projects don't work

How to start

This chapter uses NetBeans Java SE project type, based on Apache Ant.

Add JDK9 EA as a Java Platform

image: Jigsaw_J_Platform.png

After adding JDK 9 EA as Java Platform to NetBeans create Jave SE project using New Project wizard. Setup the project to JDK9 in project Properties:

  1. In Libraries customizer set Java Platform to your JDK 9 EA Java platform.
  2. In Sources customizer set Source /Binary Format to JDK 9

Add module-info.java

Then add module-info.java. It is available under New File templates in category Java.

image: Jigsaw_New_m-i.j.png

When adding module-info.java to existing application with some libraries on CLASSPATH then last step of New Java Module Info wizard lists these libraries.

image: AddModuleInfo.png

It is possible to decide whether libs should stay on CLASSPATH or to be moved to MODULEPATH. See State of the module system paper, section Compatibility and Migration on how jar files without module-info are treated by JDK9

java.base module is by default added to any JDK9 app. You can now edit module-info.java with requires,...

Project dependencies

Dependencies on Java Platform modules e.g. java.scripting is done in module-info.java file.

image: Jigsaw_m-i.j.png

Project can have also dependency on another JDK 9 EA modular (module-info.java) NB project. Use Project Properties | Libraries customizer to add another project either into modulepath or classpath. Use Add Project... button.

image: Jigsaw_Libs.png

This customizer was redesigned from previous NetBeans versions to adapt to coexistence of modulepath and classpath in JDK 9.

JUnit tests

NetBeans currently supports JUnit tests which are part of same module as tested sources. If interested how modulepath, classpath, addExport, addmods, addReads are handled to run Junit tests then read this thread: JUnitTask + JDK9 question

image: JunitTestsInModule.png

The structure is very similar to non-modular Java development. Simply add JUnit tests into Test Packages or leverage existing JUnit tests in a project. Then run the tests using project context menu Test Alt+F6. Action Test File (Ctrl+F6) for single Java file does not work at this moment.

We are working on a way to allow JUnit tests to be stored in extra module inside Java SE project which is more complex use case.

Other Features

Module Dependency Graph

The Graph View of the module-info.java file provides module dependency graph.

image: ModuleGraph.png

Running NetBeans on JDK9 EA as run time Java platform

It is possible to try this NetBeans build to run on JDK9 EA build as NetBeans IDE runtime platform. Use it with care as JDK9 EA is still under development as well as NetBeans JDK9 branch. We adopt NetBeans JDK9 to JDK9 EA changes but in some cases it takes some time.

Necessary command line options are in nb_install_dir/etc/netbeans.conf file. If you discover you need to -add-export another JDK module then add it in this file and file a bug for NB JDK9.

Changing NetBeans JDK runtime platform

How to change a JDK NetBeans uses for runtime is specified FaqJdkHome or in FaqNetbeansConf.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo