I am using Gradle with intellij.
I refresh Gradle and then I rebuild my project.
I get the following
Notice the first line - Using:javac 1.8.0_65
But I get the error that I should use -source7 or higher.
I also set the following at the settings
(With all of the inner modules are set to project sdk (1.8))
But I still can't rebuild or compile without this error.
Any suggestions?
(obviously i deleted all my classes and jars and then Gradle refreshed and rebuild project)
Same issue; got it solved with the following:
Go to: File / Settings / Build,Execution,Deployment / Build Tools /
Gradle / Gradle JVM
Then choose: Use JAVA_HOME
As of your second screen, make sure that all your modules are using the project default SDK, like in the screen below. The module setting may somehow be set to point older java version.
I had this problem while trying to build Android Studio. I kept getting
Tools need to be compiled with Java 1.8, you are using Java 11
Everything in the Intellij global and "Project Structure" settings was set to Java 1.8 so I couldn't figure out what was going on. For whatever reason, what ended up working was going to Build, Execution, Deployment > Build > Gradle and selecting the Amazon corretto version of Java 1.8 as installed by sdkman. This is baffling since I'd already tried selecting two other options for Gradle JVM that said 1.8 and both of those still resulted in the same error message as a result of Java 11 being used.
I finally resolved this issue for myself. I'm on Windows and it turns out the order in which the JDKs are listed in the Windows environment variable matter, and overrode what IDEA had set.
Although my project has JDK11 listed everywhere, JDK17 was still being used. I was able to finally resolve this issue by moving their ordering to list JDK11 first.
before I swapped the env var order
after (hurray!)
Related
In IntelliJ, what is the difference between the Gradle JVM setting (first screenshot) and the Project SDK setting (second screenshot)?
Without IntelliJ, I sometimes do ./gradlew build and I'm using Java 11 to build - which of the above settings does this translate to exactly? That is, what is the equivalent concept these two settings map to in the CLI? I think this would help me understand my initial question better.
When importing existing projects - IntelliJ uses the Project SDK version as the default Java for Gradle as well. but you can override if you wish.
seee https://www.jetbrains.com/help/idea/gradle.html#gradle_jvm
I'm using the linux beta installation on my chrome-book, and I'm trying to set up a project to use the jdk version 1.8. I previously had a project set up that uses jdk 1.11, and now it seems that even though the current project is configured to use jdk 1.8 in project settings etc, the maven installation used by intellij is still configured to use jdk 1.11. When I run java -version and mvn -verison in the intelliJ terminal, java 11 turns up. I tried changing the maven settings as well, but whenever I try to mvn compile and install, I get the following error:
/usr/lib/jvm/jdk1.8.0_271/bin/java: 1: /usr/lib/jvm/jdk1.8.0_271/bin/java: Syntax error: "(" unexpected
I can't figure out why this is happening, but it must be the fact that maven thinks this is java 11, when it's java 8. Does anyone know how to fix this?
CTRL-ALT-SHIFT-S / Project / Project SDK - you can choose existing or add configure another one
It turns out I had downloaded jdk-8u271-linux-arm64.tar.gz instead of jdk-8u271-linux-x64.tar.gz, which is why the code wasn't recognized after installing the jdk. Apparently the two are designed for different CPU architectures, and arm is for mobile devices, and wasn't compatible with my chromebook.
I'm running a Linux Ubuntu 18 OS. Installed jdk in a custom local directory.
Normally, IntelliJ recommends that you use the default gradle wrapper. But in my case, I want to be able to change the Gradle Version on the fly whenever it's due for an update.
If you use IntelliJ with Gradle, and you bump into the following error:
Could not determine java version from '11.0.1'
If you use IntelliJ
Checks:
Navigate to:
File >> Settings >> Build, Execution, Deployment >> Build Tools >> Gradle.
Alongside Gradle JVM:
make sure you select the correct version of Java.
Navigate to:
Right-Click 'Project Root Directory' & Select Open Module Settings. Project Structure windows shows-up. Make sure your JDK home path is added to the Platform Settings >> SDKs : JDK home path
Still, on the same window Project Structure, select correct SDK relevant to your project under
Project Settings >> Modules : Module SDK
Fix/Solution:
Nvavigate to & open: gradle/wrapper/gradle-wrapper.properties & update the distributionUrl version to the latest version.
In my case (at the time of this post), my older version was:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
And my latest version is:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip
As shown below:
In your build.gradle file make sure you set:
sourceCompatibility = 11
If you are using the latest version of intellijIdea.
In my case, 2019.1 -version
Delete the directory idea's jdk
then RESTART idea.
for detail see this pic
Hope this is working for you !
In chinese:
(If you can't read chinese,you needn't to read this.All you need to know have typed above already)
如果你是用最新版本的intellijidea.由于intellijidea默认安装了11的java。而且就算你输入java -verison,告诉你是java8,在ide里面也配置了java 8 idea还是告诉你这个错误。
只有通过删除idea自己下载java11版本,可以解决这个问题。直接删除应用包下的jdk文件夹,重启idea就可以。如下图。
Your gradle is too old for that JDK, upgrade your gradle or downgrade you JDK
I noticed a subtlety in the way you download the IDE from jetbains.com
You probably want JBR 8 and not JBR 11. Also, make sure your JDK is setup properly with jbsdk bintray downloader plugin.
I recently upgraded my Ubantu to 18 from 16. After that I am facing this issue. Problem was during ubantu upgrade java is automatically upgraded to 11 from 8. Hence getting this error. You can simply downgrade jdk using this to solve this. Works for me.
Reintalling Intellij Worked for me.
You need to uninstall first before reinstall. While uninstalling, ensure to select option to delete older cache and settings
check , maybe you have 2 times gradle in path
MODIFY default Boot JDK
OPEN the Action Dialog
SEARCH : switch boot jdk
SELECT the JDK installed by you rather than the intellij default
RESTART intellij idea
IGNORE this popup at right-bottom on IDE
HOPE this solution is work for you .
I'm rather new to IntelliJ IDEA and Grails in general. I just started a new Project, selected my project JDK (11.0.1) and Gradle distribution (4.10.2). Whenever I try to run the project, I get this error:
Error initializing classpath: Could not determine java version from
'11.0.1'. java.lang.IllegalArgumentException: Could not determine java
version from '11.0.1'. at
org.gradle.api.JavaVersion.toVersion(JavaVersion.java:68) at
org.gradle.api.JavaVersion.current(JavaVersion.java:78) at
org.gradle.internal.jvm.UnsupportedJavaRuntimeException.assertUsingVersion(UnsupportedJavaRuntimeException.java:29)
at
org.gradle.tooling.internal.consumer.ConnectorServices.checkJavaVersion(ConnectorServices.java:66)
at
org.gradle.tooling.internal.consumer.ConnectorServices.close(ConnectorServices.java:53)
at
org.gradle.tooling.internal.consumer.DefaultGradleConnector.close(DefaultGradleConnector.java:57)
at
org.grails.cli.gradle.cache.CachedGradleOperation.call(CachedGradleOperation.groovy:78)
at
org.grails.cli.GrailsCli.populateContextLoader(GrailsCli.groovy:525)
at org.grails.cli.GrailsCli.initializeProfile(GrailsCli.groovy:508)
at
org.grails.cli.GrailsCli.initializeApplication(GrailsCli.groovy:306)
at org.grails.cli.GrailsCli.execute(GrailsCli.groovy:269) at
org.grails.cli.GrailsCli.main(GrailsCli.groovy:159)
All other discussions of the problem I found suggested changing the Gradle distribution, which I already did. I would be so happy if anybody could help me out here.
Cheers!
May be your java configuration is not correct. If not correct follow this steps.
Goto File-> Project Structure.
Change SDK
Or gradle version is not matching jdk 11 then skip this answer.
Besides the issue with Gradle above, if you're trying to run a Grails project I don't think you can do that with JDK higher than version 8.
Even the latest Grails (3.3.8 as of this writing) is still based on SpringBoot 1.5 which does not support newer JDK, I don't know if there's a special trick to make it work.
I had to delete the .gradle directory and restart Intellij.
I just updated to Android Studio 2.2.1 for Mac. Then I updated the JDK to version 8. Tried to start a new project and run it. I got the following error:
Error:(1, 1) A problem occurred evaluating project ':app'.
java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
I also tried going back to JDK version 7 as it says on google site that JDK 8 is unstable for Mac. still got the same error.
Check your android build tools dependencies. In your build.gradle if its something like:
classpath "com.android.tools.build:gradle:+"
It has likely downloaded the alpha of 2.2 and that can cause the error you are seeing.
Try
classpath "com.android.tools.build:gradle:2.1.0"
If you are already using the right build tools version but keep getting this error, maybe one of the third party Android libraries you are using is causing the problem due to the same reason. You can force the dependency version to be used (including transitive) by changing
classpath "com.android.tools.build:gradle:2.1.0"
to
classpath('com.android.tools.build:gradle:2.1.0') {
force = true
}
Documentation: gist and official gradle docs.
I was also facing same problem. I upgraded Android Studio and as it forced to But we need to configure same in App Settings as well.
You can try to update JAVA_HOME to point to JDK 8 location.
In my case, I've updated Android studio project's SDK settings, changed java version in my PATH env variable, but still this error occured. Only updating JAVA_HOME helped me.
I was also facing the same problem. I upgraded Android Studio and as it forced to install JDK 8, downloaded and installed this as well. But we need to configure same in App Settings as well.
Select Project [Right click on the app module] -> Open Module Settings -> Select SDK Location from Left Menu - > Configured correct JDK Version i.e removed the old version and updated path of JDK. Save.
Sync Project.
Problem solved!
EDIT: Elaborated Project word.
If you are on Jenkins, check Java version in Jenkins->Manage Jenkins->Global Tool Configuration->JDK
I had to update mine to JDK 8.
I had same error in 2.3 beta 1 ,
Fixed as follow :
Download latest java jdk
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
In Android Studio , go to File > Project Structure > SDK Location > select JDK Location path to point to the new jdk installed (Ex: C:\Program Files\Java\jdk1.8.0_111 )
Done !
Ufff, I changed like everything I was able to find to jdk 8 and still no result but then I found Gradle settings in Intellij (preferences > gradle > GradleJVM) and it was ofc wrong, changed that and woala.
I meet the problem too, but I have changed nothing before it's happening. I think google is purposely. Google is trying to use openJDK instead of JDK because of the lawsuit between google and oracle. So, in the new version 2.2.0 of android, we found that there are some new files in the installed folder:
android studio 2.1 files
android studio 2.2 files
Then, I think we have two method to fix it:
Change the JDK environment variable of your OS.
Just click menu File --> Project Structure, choose Use embedded JDK (recommended). I chose this way and it work.
Good luck...
I had a same problem what is work for me is that .
Go
*File>Settings>(on the panel left)Build,Execution,Deployment . then click on Gradle
There is option to Update Gradle. Click on that it will time 3 to 4min and after that error gone.
The simplest way is to update Android Studio to v2.2.3, it includes a fix of JDK8:
Bug fix for a JDK8/Kotlin compiler + dx issue (issue 227729)
It's solved my problem.