Gradle JVM vs Project SDK settings in IntelliJ - java

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

Related

How can I switch java verisons in intelliJ?

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.

Why is IntelliJ IDEA unable to determine java version?

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.

Intellij build after gradle refresh fails on wrong java version

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!)

Install e(fx)eclipse in Eclipse Mars

I tried to install e(fx)eclipse tools in Eclipse Mars but it not successful and show that message when I start Eclipse:
You are not running your eclipse instance with Java8. The JavaFX tooling is disabled because of this.Make Java8 the default system java or adjust your eclipse.ini to pass -vm pointing to your Java8 install.
In case you want to turn off this check open your preferences and go to General > Startup and Shutdown and uncheck 'JavaFX Tooling Java Check"
Could anyone help me about this?
As stated an update might be everything you need. I had a similar issue under Linux once, where there were two JVMs installed and the older one was in the projects build path.
You can check under the projects properties -> java build path if Java 1.8 is shown there.
Regarding tools: I don't think you'll need any. Try and get familiar with the JavaFX Scene Builder. It makes building a simple GUI super easy.

enum should not be used as identifier, since it is a keyword from source level 1.5 error in maven project

I created a maven project in myeclipse project as:
1) mvn clean install
2) mvn eclipse:myeclipse
I, then, imported project into myeclipse but I got loads of build errors like
enum should not be used as identifier, since it is a reserved keyword from source level 1.5...
I have used maven 3.2.5 for building and creating project with maven.
I am using myeclipse 10.7.0 with Java 1.7.0 JDK.
Please help.
You have a variable with name enum. Since enum is a reserved word in java 1.5 or higher you should rename the variable.
For more information you should add your code and the stacktrace.
From the error message, it looks like you have a project that is defined as a Java 1.4 (or earlier) project, but you have Java 1.5 code (enums) and that is producing the Java editor validation messages. Check your pom to see if it defines a Java source level. If so, ensure it is correct, or else define one, or change the java compiler level in the project properties. If you change the pom, make sure you right click on the project and select Maven4MyEclipse->Update Project.
Just an additional note. You do not need to run mvn eclipse:myeclipse to import a maven project and this is likely to result in a bad MyEclipse project as that Maven plug-in is not provided with MyEclipse. Instead, use Import->Maven4MyEclipse->Existing Maven Projects.
A further note is that 10.7 is no longer fully supported, it's recommended that you switch to the latest release (2015 Stable 1.0 or 2015 CI 11).
The problem has been solved by installing latest version of the eclipse. It automatically installed the m2e for myeclipse and compiled the projects without any errors.

Categories