Closed shanewaz-abbas closed 4 years ago
As the message states, JDK 11 is now required to run the vscode-java extension. See https://github.com/redhat-developer/vscode-java/wiki/JDK-Requirements for more details. Warnings about this change have been displayed since mid-April (https://github.com/redhat-developer/vscode-java/blob/master/CHANGELOG.md#0600-april-16th-2020)
@akaroml @jdneo @testforstephen @Eskibear can you make sure the Java extension pack JDK requirements align with vscode-java?
As the message states, JDK 11 is now required to run the vscode-java extension. See https://github.com/redhat-developer/vscode-java/wiki/JDK-Requirements for more details. Warnings about this change have been displayed since mid-April (https://github.com/redhat-developer/vscode-java/blob/master/CHANGELOG.md#0600-april-16th-2020)
So I can still run my project without making changes, I just have to use jdk 11? Or did I misunderstand?
Wiki page says it all:
Do I need to migrate my projects to Java 11?
NO you don't! Well you should, be we're not here to judge. It is still possible to compile/run Java applications from Java 1.5 to 14, provided the proper
java.configuration.runtimes
are configured in the user's settings.json.
Even without setting java.configuration.runtimes
, if you only have JDK 11 (or more recent) configured to run vscode-java, provided your project define compilation source/target, nothing will change
@shanewaz-abbas What are the steps you took to downgrade to 0.64.1? My company and most are reliant on Java 8, not 11 so this change is messing a lot of programmers up.
@seanGammage you can still compile your projects with Java 8. JDK11 is only required to run vscode-java. See https://github.com/redhat-developer/vscode-java/wiki/JDK-Requirements for more details
Hey @seanGammage it seems like you can point to jdk 11 and it wouldn't impact running the project, though I haven't tried it as I am busy at the moment, and the downgrade was sufficient for me. To downgrade, you just have to go the java extension page and install another version and then reload.
Awesome, thank you! @fbricon and @shanewaz-abbas
I noticed the new version tries to detect the language version used by the project (JavaSE-1.5) - how do I manage these? Any config? All these projects are not Maven/Gradle but are old Eclipse projects using IVY, so I can't just go ahead and modify them mindlessly. What I found out that there were some old Eclipse extension-settings stored with source-level set to 1.5 - I adjusted them to 1.8 (like the projects now require). But in the status bar there was still the JavaSE-1.8 mentioned ... in the old version everything worked in that regard, there weren't any issues with the projects.
For now I also downgraded, until I get to understand how the runtime-configs work and how I can assign them to my Eclipse legacy-projects. I tried to config it like this:
"java.home": "C:\\AdoptOpenJDK\\jdk-11.0.8.10-hotspot",
"java.configuration.runtimes": [
{
"name": "JavaSE-1.8",
"path": "C:\\Java\\openjdk8u181-b13",
},
],
A bit off-topic but while we're at it: The Eclipse-Importer seems to ignore the "java.import.exclusions" config completely.
@thiscantbeserious Basically, the setting java.configuration.runtimes
won't change the language level of your project (except for the standalone files). This setting is used to tell the language server where different versions of the JDK are installed. The language server will pick up the matchest one according to your project's configuration.
Would you mind to share the content of this file .settings/org.eclipse.jdt.core.prefs
That's the file(s) that previously had source-level set to 1.5 - I've adjusted these for the other projects and it happened to work fine judging from the code-completion for example with lambdas. From my quick test the new version didn't happen to catch it up in the status-bar ... I can't update to the new version right now since I need to finish a task but I'll try it later and will report back if there's any issues or if it was just a hiccup. Indeed I'm using the above config running the extension with OpenJDK 11 for now ... and it seems to work fine on 0.64.1, so at least that shouldn't be a blocker for me.
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.8
@all:
I can confirm the last version works fine with our legacy projects requiring JDK8. That's how I've set it up:
"java.home": "C:\\AdoptOpenJDK\\jdk-11.0.8.10-hotspot",
"java.configuration.runtimes": [
{
"default": true,
"name": "JavaSE-1.8",
"path": "C:\\Java\\openjdk8u181-b13",
}
],
Notice the default flag - that was the JDK I was previously using and require in most projects. JAVA_HOME still points to C:\Java\openjdk8u181-b13.
I understand @fbricon considers this fixed and closed and forgotten...
... but how is this working for Android developers which are struck on JDK 8? Android SDK is super fragile and does not behave well in multi-JDK setups.
If you are like me and don't like to upgrade java version just to keep using the extension this is a simple trick you can do. Go to extensions, settings then install version 0.64.1 which still works fine with java8
As to the previous post.
You should not do this if you have no other restrictions. The most plausible restriction could be that you use Windows 32bit, and you must use a JDK like Oracle JDK or OpenJDK that is not offered for 32bit higher than version 8.
In the usual case: upgrade, and then you can still go back to using an older java version by changing the settings according to https://github.com/redhat-developer/vscode-java/issues/1543#issuecomment-662570464, for detailed instructions look at the following post.
(for Windows-10 x64)
CTRL+,
...
"java.home": "C:/Program Files/RedHat/java-11-openjdk-11.x.x-x",
"java.configuration.runtimes": [
...
{
"name": "JavaSE-1.8",
"path": "C:/Program Files/Java/jdk1.8.0_121",
},
{
"name": "JavaSE-11",
"path": "C:/Program Files/RedHat/java-11-openjdk-11.x.x-x",
},
],
(java-11-openjdk-11.x.x where x = sub version number)
In your your project's ".classpath" file you can determine the version by this line:
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
As you can see here i am using JavaSE-1.8 (Reference-image of a Project)
Why JDK 11 needs to be installed? Because it is need for running "Java Language Server"
I have installed Java 11 on my Mac, set it as default and I'm still getting this error. Instead of focusing on productivity I have this headache today.
I have installed Java 11 on my Mac, set it as default and I'm still getting this error. Instead of focusing on productivity I have this headache today.
@jnorkus Save yourself the time and revert to a previous version e.g. 0.64.1 see how here: https://github.com/redhat-developer/vscode-java/issues/1543#issuecomment-669895753
@jnorkus what system are you using? On Linux, flatpacked vscode doesn't have access to the local JDK for instance. It's also possible the JAVA_HOME environment variable wasn't picked up by vscode. You might want to try setting the "java.home" setting directly in vscode's user settings.
@gajduk I hope you're not using Eclipse, because you'll be in for a surprise next month then.
@gajduk I was just quoting the recommendation at https://github.com/redhat-developer/vscode-java/wiki/JDK-Requirements#about-the-java-11-requirement. There were 5000 views on the Stack Overflow thread https://stackoverflow.com/questions/63043585/vscode-showing-java-11-or-more-recent-is-required-to-run-please-download-and-i/63287737#63287737 in the first week after the version change, since no one was prepared - it was announced on github since April, but who reads it (I accidentally did). The rules of Stack Overflow are that any threads that simply inform are off-topic, you need a problem to be solved. And if a problem of course occurs only after the version change, a new Stack Overflow thread in the first week with 5000 views and an urgent and pinned issue here on GitHub are not surprising.
EDIT: I just see at https://github.com/redhat-developer/vscode-java/issues/1543#issuecomment-672009093 below that it was also announced on vscode java startup! Still enough people have not prepared this, forgetting such messages after a click on "Don't show again".
@jnorkus what system are you using? On Linux, flatpacked vscode doesn't have access to the local JDK for instance. It's also possible the JAVA_HOME environment variable wasn't picked up by vscode. You might want to try setting the "java.home" setting directly in vscode's user settings.
It's MacOS Mojave. I actually found a fix. Turns out the extension does not care about my JAVA_HOME
and instead just points to the /Library/Java/Home
symlink.
At the risk of repeating myself, the announcement was done on vscode java startup since the April release :
The link opened the wiki page.
It was also regularly referenced on https://twitter.com/VSCodeJava.
@fbricon I will not be surprised next month because unlike this extension, eclipse does not update when there is a breaking change like that. My current installation will continue working just fine until I manually decide to download a new version. This is how it should be. I tried to explain this, but I guess there is no point since you have already made up your mind. Good luck to you!
@gajduk
My current installation will continue working just fine until I manually decide to download a new version. This is how it should be.
Well, that choice of keeping auto-updates on or off for extensions is with the user. If you had kept auto-updates on for your VSCode extensions then you should be ready to handle new versions of the extensions.
This isn't specific to the java extension btw.
java.configuration.runtimes
doesn't work for gradle. Our project uses 4.5.1 and language support init fails with message from gradle, that it "cannot determine Java version from '11.0.8'" even after i've added the 1.8 runtime as default one.
java.import.gradle.java.home
is ignored as well
@lightrow JDK 11 requires gradle >=5.0. See https://docs.gradle.org/5.0/release-notes.html#java-11-runtime-support
Even without setting
java.configuration.runtimes
, if you only have JDK 11 (or more recent) configured to run vscode-java, provided your project define compilation source/target, nothing will change
According to my experience, I should still configure the java.configuration.runtimes
option, so that the correct jdk can be used for compilation and debugging.
Btw this is horrible
java.configuration.runtimes
doesn't work for gradle. Our project uses 4.5.1 and language support init fails with message from gradle, that it "cannot determine Java version from '11.0.8'" even after i've added the 1.8 runtime as default one.
java.import.gradle.java.home
is ignored as well
I'm having the same issue. I have Java 11 set to be used as the JDK for the extension, and tried setting JDK 1.8 as default runtime. This java extension refuses to load a gradle project that uses 2.9, with :
Could not create an instance of Tooling API implementation using the specified Gradle distribution 'https://services.gradle.org/distributions/gradle-2.9-bin.zip'. Could not create service of type FileWatcherFactory using GlobalScopeServices.createFileWatcherFactory(). Could not determine java version from '11.0.8'.
@atg22896 Java LS uses JDK11 which requires gradle >=5.0. See https://docs.gradle.org/5.0/release-notes.html#java-11-runtime-support
I agree with LiyYing, its time to find an alternative, or spend a lot of time moving your project to java 11.
On Tuesday, September 15, 2020, 7:14 AM, LiuYing notifications@github.com wrote:
They want to force you to use java 11, don't use it, I just switch to IDEA.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
@gajduk
There is no need to move your projects to JDK 11. JDK 11 is only required to launch the java language server. Your projects can still use JDK 8 to build and run. (https://github.com/redhat-developer/vscode-java/issues/1543#issuecomment-663382692)
@gajduk
There is no need to move your projects to JDK 11. JDK 11 is only required to launch the java language server. Your projects can still use JDK 8 to build and run. (#1543 (comment))
@jdneo Not if you are using a Gradle version lower than 5.0. My work uses Gradle 2.9, and JDK 8. As @snjeza said above to me, those two are incompatible with the latest version of the language server. So I have to rollback the extension, or use another piece of software.
Currently running to the same issue as @atg22896 but with gradle 4.0.2. Set all settings necessary to make vscode-java find JDK11. Also used vscode-java gradle properties below to configure JDK8 for Gradle but with no success.
"java.import.gradle.wrapper.enabled"
"java.import.gradle.version"
"java.import.gradle.home"
"java.import.gradle.java.home"
Is there really no solution to this? For our projects we are depending on a Framework which requires gradle 4.0.2 and jdk8.
this are my settings:
"java.errors.incompleteClasspath.severity": "ignore",
"java.configuration.updateBuildConfiguration": "automatic",
"java.import.maven.enabled": true,
"java.import.gradle.enabled": true,
"java.trace.server": "messages",
"java.configuration.checkProjectSettingsExclusions": false,
"java.home":"C:\\Program Files\\AdoptOpenJDK\\jdk-11.0.8.10-hotspot",
"java.configuration.runtimes": [
{
"name": "JavaSE-1.8",
"path": "C:\\Program Files\\Java\\jdk1.8.0_201",
"default": true
},
{
"name": "JavaSE-11",
"path": "C:\\Program Files\\AdoptOpenJDK\\jdk-11.0.8.10-hotspot"
}
],
"java.semanticHighlighting.enabled": true,
"java.imports.gradle.wrapper.checksums": [
...
],
"java.import.gradle.wrapper.enabled": true,
"java.import.gradle.version": "4.0.2",
"java.import.gradle.home": "C:\\Gradle\\gradle-4.0.2",
"java.import.gradle.java.home": "C:\\Program Files\\Java\\jdk1.8.0_201",
"java.server.launchMode": "Hybrid",
"java.requirements.JDK11Warning": false,
It's MacOS Mojave. I actually found a fix. Turns out the extension does not care about my
JAVA_HOME
and instead just points to the/Library/Java/Home
symlink.
@jnorkus did you solve this? I'm facing the same issue. Completely wasted my day on this. 😤
@jnorkus did you solve this? I'm facing the same issue. Completely wasted my day on this. 😤
@vizhnu I did. You have to make sure the /Library/Java/Home
symlink points to the correct JDK 11 Home. In my case it's /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
I'm still dealing with this issue as well. I'm on a restricted machine so I can't change my environment variables but I have a java.configuration.rutimes array with both Java 11 and the JDK that I need for my project and when I open "Configure Java Runtime" I only see that one. So then I add a java.home to my project settings and Java 11 disappears and the plugin breaks with the "Java 11 or more recent is required to run..." error.
Just found a working solution: https://devblogs.microsoft.com/java/about-upgrading-to-java-11-for-vs-code-for-java
Basically the java.home needs to point to java 11 and then in your java.configuration.runtimes array need to ONLY have the runtime you want your project to be in. This is annoying because you can't put the java.configuration.runtimes array in your projects settings.json, only in your machine/remote machine's settings.json
Hope this helps
@jjoker0110 thanks. That helped to solve my problem.
I have got path bellow by running echo $JAVA_HOME
in the openjdk:11 container.
Setting java.home in my devcontainer.json was probably enough to make it run.
{
//...
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": null,
"java.home": "/usr/local/openjdk-11"
}
//...
}
I installed gradle too. I do not know if I had to.
RUN wget https://services.gradle.org/distributions/gradle-6.3-bin.zip -P /tmp && \
unzip -d /opt/gradle /tmp/gradle-6.3-bin.zip
# todo rm gradle zip
ENV GRADLE_HOME /opt/gradle/gradle-6.3
ENV PATH ${GRADLE_HOME}/bin:${PATH}
So there is still no solution for using older Gradle versions?
@atg22896: If you are using a gradle version below 4.7 the "workaround" is to stick with vscode-java v0.64.1 until you are able to update the gradle version.
@atg22896: If you are using a gradle version below 4.7 the "workaround" is to stick with vscode-java v0.64.1 until you are able to update the gradle version.
So always use 0.64.1, got it. 😄 Sadly all my work projects use Gradle 2.X and it's not like I can make the whole company use an updated Gradle.
If you are like me and don't like to upgrade java version just to keep using the extension this is a simple trick you can do. Go to extensions, settings then install version 0.64.1 which still works fine with java8
Does your VSCODE also display this interface every time you start it?
@V-arc The latest Language Support for Java
has embedded a JDK to launch itself, so there is no need to download another JDK11 to launch it. Please try the latest one and see if it works.
@jdneo Great! I just upgraded Language Support for Java
to version v1.2.0 and it worked without warning. Thanks!
@V-arc The latest
Language Support for Java
has embedded a JDK to launch itself, so there is no need to download another JDK11 to launch it. Please try the latest one and see if it works.
How about gradle support ? Do I need to update my projects gradle ? Because I need to stick with Gradle 4.0.2.
@Bno93
I think you can try to set the setting java.import.gradle.java.home
, use it to point to your own JDK which is compatible with Gradle 4.0.2
@jdneo seems find even without setting java.import.gradle.java.home
. I've removed every generated files and folders and additionally cleared Java Language Server Workspace to make sure that I don't ran into problems opening fresh projects in the future.
I don't understand why today I'm getting this error. Managed to temporarily solve this by downgrading
Language Support for Java(TM) by Red Hat
to 0.64.1.Environment