Skip to content

Support to set Project level JDK #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,21 @@
[![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)
[![License](https://img.shields.io/github/license/oracle/javavscode?style=for-the-badge&logo=apache)](https://github.com/oracle/javavscode/blob/main/LICENSE.txt)

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.

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.
## Getting Started
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)
2. If no JDK is present in your system then extension can setup things for you. More below in section [JDK Downloader](#jdk-downloader)
3. Use __Java: New Project...__ " command to start creating new project, or
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
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.
1. Setting up the JDK
- 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.
- 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.
- The extension requires JDK 17 or newer to run.
- Optionally, set a different JDK to compile and run projects in the `View | Command Palette | Preferences: Open User Settings | Jdk › Project: Jdkhome` setting.
- By default, the __jdk.jdkhome__ setting is used.
- Projects can run on JDK 8 and above.
- For more information, see the section [Selecting the JDK](#selecting-the-jdk).
4. Use any one of the following ways to start coding, compiling and debugging in Java.
- Simply create a new Java class with `public static void main(String[] args)` method.
- Use the __Java: New From Template...__ command to create a new Java file.
- Use the __Java: New Project...__ command to create a new project.
- Open the folder with existing __Maven__ or __Gradle__ project files (_pom.xml_ or _build.gradle, gradle.properties_).

## Supported Actions
In the VS Code command palette :
Expand Down Expand Up @@ -159,19 +166,11 @@ When adding JavaDoc to code Oracle Java Platform extension assists by suggesting
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.
![Test Explorer](vscode/images/Test_explorer.png)

## Supported Options

* __jdk.jdkhome__ - path to the JDK, see dedicated section below
* __jdk.verbose__ - enables verbose extension logging

## Selecting the JDK
The JDK to build, run and debug projects is being searched in the following locations:

The user projects are built, run and debugged using the same JDK which runs the
Oracle Java Platform extension. The JDK is being searched in
following locations:

- `jdk.project.jdkhome` setting (workspace then user settings)
- `jdk.jdkhome` setting (workspace then user settings)
- `java.home` setting (workspace then user settings)
- `JDK_HOME` environment variable
- `JAVA_HOME` environment variable
- current system path
Expand Down
1 change: 1 addition & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
patches/7370.diff
patches/7382.diff
patches/7491-preliminary.diff
patches/7497.diff
patches/7548_source-1.8.diff
patches/7583_source-1.8.diff
patches/7610.diff
Expand Down
9 changes: 9 additions & 0 deletions nbcode/integration/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.java.platform</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>1.66</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.parsing.api</code-name-base>
<build-prerequisite/>
<compile-dependency/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.modules.nbcode.integration;

import org.netbeans.modules.java.lsp.server.ui.AbstractJavaPlatformProviderOverride;
import org.netbeans.modules.java.platform.implspi.JavaPlatformProvider;
import org.openide.util.lookup.ServiceProvider;

/**
*
* @author sdedic
*/
@ServiceProvider(service = JavaPlatformProvider.class, position = 10_000)
public class LspJavaPlatformProviderOverride extends AbstractJavaPlatformProviderOverride {
}
Loading