.classpath keeps changing to Java 1.8, not what is in pom.xml (11)
See original GitHub issueI have a project that was generated by JHipster that has always used Java 11, which is specified in the POM.
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
However, every time .classpath is generated it specifies Java 1.8:
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
Then I have manually change it to java 11:
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
This is similar to this issue .classpath file is not updated with new JDK version #1748 where they said to manually trigger a configuration update with the “Update Configuration” command. I have done that and it also changes it to Java 1.8 😕
Environment
- Operating System: Windows 10 Enterprise 10.0.19044 Build 19044
- JDK version: 11
- Visual Studio Code version: 1.68.0
- Java extension version: v0.23.0 (Last updated 6/12/2022, 20:07:00)
Steps To Reproduce
- manually trigger a configuration update with the “Update Configuration”
- Java version changes to 1.8, NOT the version in pom.xml
[Please attach a sample project reproducing the error] Please attach logs
Current Result
.classpath is configured for Java 1.8, not the version specified in pom.xml
Expected Result
.classpath should match the pom.xml file, which is configured for Java 11
Additional Informations
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Java version automatically change to java 1.5 after maven ...
I changed "Java build path" to "workspace default jre 1.8.0_25" · Then changed "java compiler" to 1.8 · Then changed "project facets">java>1.8 ·...
Read more >How to force JDK 1.8 compliance in a Maven POM example
The only way to make this a permanent change is to edit the Maven compiler plugin POM entry and force Eclipse and Maven...
Read more >Transition from Java 8 to Java 11 - Azure - Microsoft Learn
In this article. The toolbox; Running on Java 11; Next steps. There's no one-size-fits-all solution to transition code from Java 8 to Java...
Read more >Setting the -source and -target of the Java Compiler
To avoid this issue, you can either configure the compiler's boot classpath to match the target JRE, or use the Animal Sniffer Maven...
Read more >Building Java & JVM projects - Gradle User Manual
compileOnly — for dependencies that are necessary to compile your production code but shouldn't be part of the runtime classpath. implementation (supersedes ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I had a very similar issue with JavaSE-11 being changed to JavaSE-12 automatically by vscode in my maven java projects. In my case it was caused by maven-enforcer-plugin. When I changed the version underneath plugin/executions/execution/configuration/rules/requireJavaVersion in
from
<version>11.0.4</version>
to<version>[11.0,12.0)</version>
, then it stopped changing the java version.Maybe it is also some maven plugin in your case causing this?
@kkalass thanks for the tip, this is what my
maven-enforcer-plugin
was set to:It doesn’t feel like I got the right result, as 1.8.0 is just the minimum and it chose 1.8 even though I have both 11 and 17, but changing that to 17 has fixed the issue with VS Code choosing 1.8 for my project in spite of the compiler plugin stipulating 17. Much thanks.