Skip to content

Commit 6310a3b

Browse files
Achal1607lahodaj
andauthored
Support to set Project level JDK (#244)
* backporting 7497 Netbeans PR * Additional registration needed to provider Java default platform override. * updated configuration * README updated * update README --------- Co-authored-by: Jan Lahoda <[email protected]>
1 parent e686355 commit 6310a3b

File tree

8 files changed

+397
-35
lines changed

8 files changed

+397
-35
lines changed

README.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,21 @@
2828
[![Build Status](https://img.shields.io/github/actions/workflow/status/oracle/javavscode/main.yml?branch=main&style=for-the-badge&logo=github)](https://github.com/oracle/javavscode/actions?query=workflow:Java%20Platform%20Support%20for%20Visual%20Studio%20Code)
2929
[![License](https://img.shields.io/github/license/oracle/javavscode?style=for-the-badge&logo=apache)](https://github.com/oracle/javavscode/blob/main/LICENSE.txt)
3030

31-
Java Platform extension from Oracle brings full featured development support (edit-compile-debug & test cycle) to VS Code. It offers support for Maven and Gradle projects.
32-
31+
Java Platform extension from Oracle brings full featured development support (edit-compile-debug & test cycle) to VS Code. It also offers support for Maven and Gradle projects. Applications using JDK 8 and above are supported.
3332
## Getting Started
34-
1. Set JDK in `View | Command Palette | Preferences:Open User Settings (JSON) ...` __jdk: 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](#selecting-the-jdk)
35-
2. If no JDK is present in your system then extension can setup things for you. More below in section [JDK Downloader](#jdk-downloader)
36-
3. Use __Java: New Project...__ " command to start creating new project, or
37-
4. Open the folder with existing __pom.xml__ for Maven or ___Gradle___ project files (_build.gradle, gradle.properties_). Language Server opens the project, resolves dependencies if any and performs priming build, or
38-
5. 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 11 and newer.
33+
1. Setting up the JDK
34+
- If no JDK is present in your system then the extension can set things up for you. For more details refer to [JDK Downloader](#jdk-downloader) section.
35+
- Set the JDK in the `View | Command Palette | Preferences: Open User Settings | Jdk: Jdkhome` setting to point to the JDK that the Language Server will run on and also by default use for running and compiling projects.
36+
- The extension requires JDK 17 or newer to run.
37+
- Optionally, set a different JDK to compile and run projects in the `View | Command Palette | Preferences: Open User Settings | Jdk › Project: Jdkhome` setting.
38+
- By default, the __jdk.jdkhome__ setting is used.
39+
- Projects can run on JDK 8 and above.
40+
- For more information, see the section [Selecting the JDK](#selecting-the-jdk).
41+
4. Use any one of the following ways to start coding, compiling and debugging in Java.
42+
- Simply create a new Java class with `public static void main(String[] args)` method.
43+
- Use the __Java: New From Template...__ command to create a new Java file.
44+
- Use the __Java: New Project...__ command to create a new project.
45+
- Open the folder with existing __Maven__ or __Gradle__ project files (_pom.xml_ or _build.gradle, gradle.properties_).
3946

4047
## Supported Actions
4148
In the VS Code command palette :
@@ -159,19 +166,11 @@ When adding JavaDoc to code Oracle Java Platform extension assists by suggesting
159166
Oracle Java Platform extension provides Test Explorer view which allows to run all tests in a project, examine the results, go to source code and run particular test.
160167
![Test Explorer](vscode/images/Test_explorer.png)
161168

162-
## Supported Options
163-
164-
* __jdk.jdkhome__ - path to the JDK, see dedicated section below
165-
* __jdk.verbose__ - enables verbose extension logging
166-
167169
## Selecting the JDK
170+
The JDK to build, run and debug projects is being searched in the following locations:
168171

169-
The user projects are built, run and debugged using the same JDK which runs the
170-
Oracle Java Platform extension. The JDK is being searched in
171-
following locations:
172-
172+
- `jdk.project.jdkhome` setting (workspace then user settings)
173173
- `jdk.jdkhome` setting (workspace then user settings)
174-
- `java.home` setting (workspace then user settings)
175174
- `JDK_HOME` environment variable
176175
- `JAVA_HOME` environment variable
177176
- current system path

build.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
patches/7370.diff
4242
patches/7382.diff
4343
patches/7491-preliminary.diff
44+
patches/7497.diff
4445
patches/7548_source-1.8.diff
4546
patches/7583_source-1.8.diff
4647
patches/7610.diff

nbcode/integration/nbproject/project.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@
112112
</run-dependency>
113113
</dependency>
114114
<dependency>
115+
<code-name-base>org.netbeans.modules.java.platform</code-name-base>
116+
<build-prerequisite/>
117+
<compile-dependency/>
118+
<run-dependency>
119+
<release-version>1</release-version>
120+
<specification-version>1.66</specification-version>
121+
</run-dependency>
122+
</dependency>
123+
<dependency>
115124
<code-name-base>org.netbeans.modules.parsing.api</code-name-base>
116125
<build-prerequisite/>
117126
<compile-dependency/>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.netbeans.modules.nbcode.integration;
20+
21+
import org.netbeans.modules.java.lsp.server.ui.AbstractJavaPlatformProviderOverride;
22+
import org.netbeans.modules.java.platform.implspi.JavaPlatformProvider;
23+
import org.openide.util.lookup.ServiceProvider;
24+
25+
/**
26+
*
27+
* @author sdedic
28+
*/
29+
@ServiceProvider(service = JavaPlatformProvider.class, position = 10_000)
30+
public class LspJavaPlatformProviderOverride extends AbstractJavaPlatformProviderOverride {
31+
}

0 commit comments

Comments
 (0)