This is a technology preview of Apache NetBeans based extension for VS Code. Use it to get all the goodies of NetBeans via the VS Code user interface! Runs on JDK8[*] and all newer versions.
Apache NetBeans Language Server brings full featured Java development (edit-compile-debug & test cycle) for Maven and Gradle projects to VSCode. As well as other features.
Set JDK in VSCode | Preferences | Settings ... Netbeans: Jdkhome setting to point to JDK which Language Server will run on and projects will be compiled with. More below in section Selecting the JDK
Use Java: New Project... " command to start creating new project, or
Open the folder with existing pom.xml for Maven or Gradle project files (build.gradle, gradle.properties).
Or simply create a new Java class file with public static void main(String[] args) method in opened folder and start coding, compiling, debugging. Works on JDK 8 and newer.
Language Server Java 8+ ... launch configuration supports debugging and running Java applications using JDK8 or newer.
Run main | Debug main code lense is selected in the code.Default launch configurations provided by Language Server can modified in launch.json file using intellisense for available options.
Class level refactorings as well as variable refactorings are supported in VSCode via Apache NetBeans extension. See following screenshots:
Some refactorings are two steps with like Override method ... where method to be overriden is selected in 2nd step:
NetBeans Language Server provides Test Explorer view which allows to run all tests in a project, examine the results, go to source code and run particular test.
Experimental Support
NetBeans Language Server allows Java like debugging of native images produced by GraalVM EE native-image tool. It is provided using GDB and via new Run configuration named Launch Native Image. This experimental feature works now only on Linux with certain version of GDB, see above. GraalVM Enterprise Edition is needed as it produces full debug information for native images, at this time.
In order to debug native image applications it is necessary to build such native image with debug information available. It can be done by providing following switches for native-image tool:
-g -O0 or-H:Debug=2 -H:Optimize=0.It is possible to use Native-Image Maven Plugin to run native-image builds for Maven projects. In this case add following <buildArgs> into plugin <configuration>:
<buildArgs> <buildArg>-g</buildArg> <buildArg>-O0</buildArg> </buildArgs>
Setting project's Maven pom.xml to skip native-image build everytime when project is being built is a good practice.
When native image is built, including debug info then add Launch Native Image configuration to launch.json. Select it in Run & Debug activity window and press F5 to debug Java source code on native image.
The user projects are built, run and debugged using the same JDK which runs the Apache NetBeans Language Server. The JDK is being searched in following locations:
netbeans.jdkhome setting (workspace then user settings)java.home setting (workspace then user settings)JDK_HOME environment variableJAVA_HOME environment variableAs soon as one of the settings is changed, the Language Server is restarted.
Apache NetBeans Language Server extension isn't the only Java supporting extension. To avoid duplicated code completion and other misleading clashes the extension disables certain functionality known to cause problems, this is done per Workspace.
This behavior can be disabled by setting netbeans.conflict.check setting to false.
Read building instructions to help Apache community to improve the extension.