Skip to content
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

.classpath keeps changing to Java 1.8, not what is in pom.xml (11) #2511

Closed
naris opened this issue Jun 15, 2022 · 6 comments
Closed

.classpath keeps changing to Java 1.8, not what is in pom.xml (11) #2511

naris opened this issue Jun 15, 2022 · 6 comments

Comments

@naris
Copy link

naris commented Jun 15, 2022

I 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
  1. manually trigger a configuration update with the "Update Configuration"
  2. 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
@fbricon
Copy link
Collaborator

fbricon commented Jun 15, 2022

please attach a sample project

@karlvr
Copy link
Contributor

karlvr commented Jun 18, 2022

I am observing the same behaviour... downgrading from 1.7.0 to 1.6.0 resolves the issue after a clean java workspace.

@snjeza
Copy link
Contributor

snjeza commented Jun 18, 2022

@karlvr I can't reproduce the issue. Could you attach a project sample?

@kkalass
Copy link

kkalass commented Jun 22, 2022

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

	<plugin>
		<artifactId>maven-enforcer-plugin</artifactId>
		<version>3.1.0</version>
		<executions>
			<execution>
				<id>enforce-java</id>
				<goals>
					<goal>enforce</goal>
				</goals>
				<phase>validate</phase>
				<configuration>
					<rules>
						<requireJavaVersion>
							<version>11.0.4</version>
						</requireJavaVersion>
					</rules>
				</configuration>
			</execution>
		</executions>
	</plugin>

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?

@karlvr
Copy link
Contributor

karlvr commented Jul 5, 2022

@kkalass thanks for the tip, this is what my maven-enforcer-plugin was set to:

<requireJavaVersion>
	<version>[1.8.0,)</version>
</requireJavaVersion>

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.

@rgrunber
Copy link
Member

This may have been related to eclipse-m2e/m2e-core#1099 so if it's still an issue, feel free to re-open. Explanation seems to be that under Eclipse, the JRE used to run the project is the same one used to run Maven.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants