JDK9Support

(Difference between revisions)
 
(27 intermediate revisions not shown)
Line 1: Line 1:
-
<h1>JDK9 EA Support</H1>
+
NetBeans has been donated by Oracle to Apache, where it continues to be actively developed. Go to [https://netbeans.apache.org netbeans.apache.org] for the latest details, go to [https://netbeans.apache.org/download/nb90/ https://netbeans.apache.org/download/nb90] in particular.
-
NetBeans IDE previews early experimental support for [https://jdk9.java.net/download/ 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.
+
 
 +
<h1>Oracle NetBeans</h1>
 +
 
 +
<h3>JDK9 EA Support</h3>
 +
'''NOTE''' Always use latest JDK9 EA build when working with NetBeans Daily development builds. Refer to [[#not_working|What does not Work chapter]] for latest updates on compatibility issues.
 +
 
 +
NetBeans IDE [http://bits.netbeans.org/download/trunk/nightly/latest/ Daily Development builds] contains also early (under development) support for [https://jdk9.java.net/download/ JDK 9 EA development builds] namely the new modular system for Java. (Download http://bits.netbeans.org/download/trunk/nightly/latest/)
 +
 
 +
Features are not complete, at this stage, and WILL break in the future. JDK 9 EA is the 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.
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. [https://netbeans.org/bugzilla/enter_bug.cgi Bugs could be filled] for JDK 9 EA support into bugzilla with Keyword '''JDK_9'''.  
+
Sources and builds are available on '''AS IS''' basis (daily development builds) without any warranty and testing. [https://netbeans.org/bugzilla/enter_bug.cgi 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 ...
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.
+
NetBeans JDK9 support development is ongoing effort till NetBeans 9 reaches its Feature Freeze mileston.  
-
 
+
-
Regular NetBeans Development builds (planned NetBeans 8.2 release) does not fully support JDK 9 and module system.
+
==Getting Started==
==Getting Started==
Line 18: Line 24:
# The NetBeans JDK 9 build runs on top of Java SE 8, you can download the latest update of [http://www.oracle.com/technetwork/java/javase/downloads/index.html Java SE 8 here]. JDK 7 and older is not supported by NetBeans after NetBeans 8.1 release.
# The NetBeans JDK 9 build runs on top of Java SE 8, you can download the latest update of [http://www.oracle.com/technetwork/java/javase/downloads/index.html Java SE 8 here]. JDK 7 and older is not supported by NetBeans after NetBeans 8.1 release.
# Download the latest JDK 9 Early Access from https://jdk9.java.net/download/ page  
# Download the latest JDK 9 Early Access from https://jdk9.java.net/download/ page  
-
# '''Download NB JDK 9 dev build''' from http://bits.netbeans.org/netbeans/nb9-for-jdk9_jigsaw/daily/latest/ or build it from sources.
+
# '''Download NB Daily Development build''' from http://bits.netbeans.org/download/trunk/nightly/latest/ or build it from sources.
-
## 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 ([[#jdk9_runtime|see below]] for instructions), you should consider configuring NetBeans (every version installed) to launch with JDK 8 (see [[#nb_faq|Changing NetBeans JDK runtime platform]] below for instructions)
+
## In some operating systems NetBeans, by default, launches on the most current JDK version available.  Installing JDK 9 EA might cause the NB 9 daily development 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 ([[#jdk9_runtime|see below]] for instructions), you should consider configuring NetBeans (every version installed) to launch with JDK 8 (see [[#nb_faq|Changing NetBeans JDK runtime platform]] below for instructions)
# Register the latest JDK 9 EA build as a ''Java Platform'' in NetBeans JDK9 build by means of ''Tools | Java Platforms | Add Platform''.
# 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==
==What works==
NetBeans JDK 9 builds support:  
NetBeans JDK 9 builds support:  
* NB Java SE project support one JDK9/Jigsaw module - Single module project.  
* NB Java SE project support one JDK9/Jigsaw module - Single module project.  
 +
* Java SE Multi module project - Ant based project containing several modules and compiling them at once.
 +
* Maven projects
* module-info.java support: editing works and using its statement to set module boundaries for projects
* 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
* All Editing features work according to what is declared in module-info.java
Line 33: Line 42:
* All other features unrelated to Java language like SCM should work.
* All other features unrelated to Java language like SCM should work.
 +
<span id="not_working"></span>
==What DOES NOT work==
==What DOES NOT work==
-
* Multiple JDK9 modules in one NB project
+
===Strong Encapsulation===
-
* Maven projects don't work
+
When running NetBeans IDE daily Dev build on top of JDK9 EA build 150 or newer you might experience issues when some APIs are not accessible, this is due to [http://mail.openjdk.java.net/pipermail/jdk9-dev/2016-November/005276.html strong encapsulation of APIs in non exported packages invoked through setAccessible()] - this no longer works in b150 and newer. Similar exception will be printed to terminal or log file:
 +
<pre>
 +
java.lang.reflect.InaccessibleObjectException: Unable to make field transient some_package.some_class.some_field accessible: module java.xyz does not "opens abc.xyz" to unnamed module @2a5ca609
 +
at ....
 +
</pre>
 +
Particular class/field/module might vary. NetBeans IDE JavaSE and JS distributions were fixed since daily build 201701130001 (Jan 13th) and now opens several packages for reflection. It might happen than when running daily dev build on top of JDK9 EA with additional modules/clusters installed then setAccessible to some other field might be used. It might be also invoked from bundled 3rd party library we even cannot fix. In such a case add a statement like this, e.g. '''-J--add-opens java.base/java.util=ALL-UNNAMED''' (provide your module and package) to netbeans.conf '''netbeans_default_options=''' and run IDE again. For modules in standard netbeans distros (Java EE,...) report the bug to NB Bugzilla using JDK_9 keyword. We will fix that in netbeans.conf in upcoming daily build.
 +
 
== How to start ==
== How to start ==
Line 78: Line 94:
[[image: JunitTestsInModule.png]]
[[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.
+
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. Junit jar file needs to be added to Test Libraries. Then run the tests using ''project'' context menu '''Test  Alt+F6'' or ''Test File'' (Ctrl+F6) for single Java file.
-
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.
+
==== JUnit tests in own module ====
 +
NetBeans also support inside Java SE single module project to place tests inside own module. This is the only case when two module_info.java files can be used in this type of project. This way tests are more like ''black box'' as they are not a part of source module, thus module boundaries and package readability among modules play a role.
 +
 +
Start by adding module_info.java into Test Packages. Rename the module to something meaningful and different from source files, e.g. testModule
 +
Then add JUnit tests into some package. Resulting structure should look like following screen shot:
 +
 
 +
[[image:Junit_in_Module.png]]
 +
 
 +
module_info.java looks like following:
 +
 
 +
[[image:Module_info_junit.png]]
 +
 
 +
NetBeans perform compilation and test execution which could replicated using these two command lines (just for illustration) using Ant junit task:
 +
* Compile: javac -mp build/classes:junit.jar -XaddExports:srcModule/pkg=testModule -XaddReads:testModule=junit -d build/test/classes test/module-info.java test/pkg/test/AppTest.java
 +
 
 +
* Run Tests: java -mp build/test/classes:build/classes:junit.jar -addmods srcModule,testModule -XaddExports:srcModule/pkg=testModule,testModule/pkg.test=junit -XaddReads:testModule=junit -cp hamcrest-core.jar -m junit/org.junit.runner.JUnitCore pkg.test.AppTest
 +
 
 +
== Maven Projects ==
 +
With release of [http://mail.openjdk.java.net/pipermail/jigsaw-dev/2016-October/009851.html Apache Maven Compiler Pluging v 3.6.0] it is possible to develop Maven projects in NetBeans 9 for JDK9. Simply open or create Maven project in NetBeans IDE. Set appropriate JDK 9 EA as Project '''Java Platform''' and change '''Source/Binary Format''' to '''9'''.<br/>
 +
If module_info.java is present in Maven project then all Java libraries used in a project became JDK9 modules - are placed to MODULEPATH by Maven Compiler Plugin.<br/>
 +
It is also possible to add declared dependencies to module_info.java via a context action on the dependency node.
 +
 
 +
[[image:add_dependency_2_nodule_info.png]]
 +
 
 +
==== Unit testing ====
 +
Unit testing is possible as of Apache Maven Compiler Pluging v 3.6.1
 +
 
 +
=== What does not work  ===
 +
NetBeans Maven support is under development to provide other productivity features for Maven projects.
 +
 
 +
==== maven-javadoc-plugin ====
 +
* failures and warnings in jar(error), javadoc(warning), aggregate(error)
 +
 
 +
==== maven-war-plugin, maven-ear-plugin ====
 +
* needs to detect new version scheme
 +
* and maybe some other plugins depending on maven-archiver
 +
 
 +
 
 +
see also https://cwiki.apache.org/confluence/display/MAVEN/Java+9+-+Jigsaw
== Other Features ==
== Other Features ==
Line 98: Line 152:
====Changing NetBeans JDK runtime platform====
====Changing NetBeans JDK runtime platform====
How to change a JDK NetBeans uses for runtime is specified [[FaqJdkHome]] or in [[FaqNetbeansConf]].
How to change a JDK NetBeans uses for runtime is specified [[FaqJdkHome]] or in [[FaqNetbeansConf]].
 +
 +
-->

Current revision as of 08:28, 21 July 2018

NetBeans has been donated by Oracle to Apache, where it continues to be actively developed. Go to netbeans.apache.org for the latest details, go to https://netbeans.apache.org/download/nb90 in particular.


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