EN
Is there way to configure Java 19 (or upper) in VS Code?
1
answers
5
points
As I noticed, VS Code supports currently Java 8, 11 and 19.
Is there way to configure Java 19 (or upper) in VS Code?
1 answer
7
points
Prerequirements: installed Java 19 on your computer (read this article).
Under Windows:
- press
Ctrl+Shift+Pkeys,
- find and select Preferences: Open User Settings (JSON) option,
- add
"java.configuration.runtimes"configuration,
e.g.:{ // ... "java.configuration.runtimes": [ { "name": "JavaSE-11", "path": "C:\\Program Files\\Eclipse Adoptium\\jdk-11.0.19.7-hotspot", }, { "name": "JavaSE-17", "path": "C:\\Program Files\\Eclipse Adoptium\\jdk-17.0.8.101-hotspot", }, { "name": "JavaSE-19", "path": "C:\\Program Files\\Eclipse Adoptium\\jdk-19.0.2.7-hotspot", "default": true } ], // ... }Note: you can use other JDK than Eclipse Adoptium.
Sometimes it may be needed to change Java version to 19 in pom.xml file when you use Maven project.
e.g.:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-project</artifactId>
<name>My project</name>
<description>My project description.</description>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<java.version>19</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<!-- ... -->
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</build>
</project>
See also
0 comments
Add comment