JDK version mismatch between Intellij project structure and Maven version - java

At project structure of Intellij, the JDK version is selected as 1.8
At Maven properties also, the JDK verison had been mention as 1.8
But still upon mvn --install somehow I get JDK verion as 11
Unable to understand the behaviour. And how do I make it as 1.8
Project screenshot

Try and change in Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Runner -> JRE to use JDK 8 or even better set the JAVA_HOME to the JDK 8

Related

How can i change the Gradle Version in InteliJ?

I have the Error: "Found invalid Gradle JVM configuration"
"JDK 17.0.1 isnĀ“t compatible with gradle 7.1. Please fix JAVA_HOME enviroment variable"
Im not sure why it says gradle 7.1. The gradle Version i have is 7.4.2. This version should work with JDK 17
Take a look at the gradle-wrapper.properties file in the ./gradle/wrapper directory.
In the file, you can define the distribution URL from which Gradle is loaded. For example:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
As far as I know, IntelliJ adopts the version.
According to the Gradle documentation, Gradle 7.3 is the first Gradle version that supports JDK 17. You could try that one.

Intellij, target JRE vesion doesn't match project jdk version

I am using Intellij Community version 2019.3 on my MacBook. I have a simple springboot (java) project. Whenever I run my unit test I get the following warning:
Where should I check on Intellij to get rid of this error? (I heard on internet "Project Settings", but I can't find where this option is)
The target JRE version for Gradle can be configured from within Intellij via the Gradle JVM setting at Preferences (cmd + ,) > Build, Execution, Deployment > Gradle:
The project JDK version can be configured from the Project SDK setting in Project Structure (cmd + ;):
(Screenshots taken from IntelliJ IDEA 2020.1.4)
This is because you are building for target version of Java 1.8
Depending what you are using, Maven or Gradle, you set the target version of java with:
Gradle
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
Docs:
https://docs.gradle.org/current/userguide/java_plugin.html#sec:java-extension
https://docs.gradle.org/current/javadoc/org/gradle/api/JavaVersion.html
Maven
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
Docs:
http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
You can change this version to 12 or JavaVersion.VERSION_12 to use your build JDK, but then you would lose the compatibility and won't be able to run the application jar with Java 1.8.
You can also change the build SDK version, on macOS press command + ; and go to Project Settings -> Project and change the Project SDK to the one you want to build it with.
Intellij + Gradle also refers to the Gradle JVM setup within Intellij.
Ensure to change that as shown below:

Gradle build project with specific jdk

I am having Grails project (grails 2.3.11) with multiple Grails plugins. One main Grails project in addition of some user defined Grails plugins and core Java project creates a complete application. So far, these projects are build using Ant builder. Recently upgraded build process to use Gradle.
Problem with gradle process is that some project needs to be build with jdk 1.7 and some to be build with jdk 1.8. In order to fix it, I have set java_home to point to jdk 1.7. Then created gradle.properties file in project directories which needs code to be build with jdk 1.8. Have set property org.gradle.java.home to point to jdk 1.8. Now when I print java_home value from such project I found that it is still picking jdk 1.7 (the one set as environment variable).
Here my gradle compileJava task:
compileJava {
options.encoding = 'UTF-8'
def env = System.getenv("JAVA_HOME")
println "Compile Java: JAVAHOME = ${env}"
dependsOn ':core:updateversiondotjava'
logging.captureStandardOutput LogLevel.DEBUG
}
Projects build with 1.7 are all Grails project and Grails user defined plugins. Reason to build them with 1.7 is to avoid grails version upgrade. Because grails 2.3.x or lower are not supporting Java 1.8.
Can anyone please guide me where I am doing wrong?
I recall Grails 2.3.11 running on Java 8 in my testing. Early versions of Grails 2.3 did not run on Java 8. I understand the official support started with 2.4.x but have you tried Java 8 with your 2.3.11 application?

Project facet Java version 1.7 is not supported

I know similar issues has been posted already in SO but unfortunately none of them helped actually.
Facing :
Project facet Java version 1.7 is not supported
Current Environment :
Server : Tomcat 7
JDK and JRE :1.6
Eclipse : JUNO
And as per the doc it seems like Tomcat 7 should support JDK 6
Ref : https://tomcat.apache.org/tomcat-7.0-doc/building.html
I checked JRE which my project pointing to
Window --> Preferences --> Java --> Installed JRE
and its pointing to JRE1.6.
Any kind of help will be appreciated.
Facet != JRE Settings ... Right Click on Project => Properties => Tabpage Project Facets...
Right Click on Project -> Properties -> Project Facets
Your project Java version here should be same as Java compiler version
Right Click on Project -> Properties -> Java Compiler
Based on your input that you want to use JDK 1.16, same should be the version of your Java Compiler and Project Facet Java version.
You can edit the java version of your run time (server)environment
In eclipse, goto Windows->Preferences->server->run time environment->select the server on the right side window->edit->In java home->select jdk1.7.0_79 path->finish

Choose Gradle JDK in IntelliJ

My system JAVA_HOME and PATH are pointing to JDK 7, but I want to use JDK 8 in project opened in IntelliJ. I changes settings in Project Structure and it works great in IDE, but unfortunately Gradle build run from IDE still uses JDK 7. How can I specify Gradle JDK in IntelliJ 13.0?

Categories