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 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 am getting some errors that had been fixed according to the 6.18 release notes and was hoping to bump the dependency version to fix the issue, but when I mvn install the project now, I get a build error
Classes found in the wrong directory: {META-INF/versions/9/com/teamdev/jxbrowser/chromium/swing/internal/AWTHelper$1.class=com.teamdev.jxbrowser.chromium.swing.internal.AWTHelper$1, META-INF/versions/9/com/teamdev/jxbrowser/chromium/swing/internal/NativeLinux.class=com.teamdev.jxbrowser.chromium.swing.internal.NativeLinux, META-INF/versions/9/com/teamdev/jxbrowser/chromium/javafx/internal/NativeMac.class=com.teamdev.jxbrowser.chromium.javafx.internal.NativeMac, META-INF/versions/9/com/teamdev/jxbrowser/chromium/javafx/internal/dialogs/ColorDialog.class=com.teamdev.jxbrowser.chromium.javafx.internal.dialogs.ColorDialog, META-INF/versions/9/com/teamdev/jxbrowser/chromium/internal/JavaVersion.class=com.teamdev.jxbrowser.chromium.internal.JavaVersion, META-INF/versions/9/com/teamdev/jxbrowser/chromium/swing/internal/AWTHelper.class=com.teamdev.jxbrowser.chromium.swing.internal.AWTHelper, META-INF/versions/9/com/teamdev/jxbrowser/chromium/swing/internal/Native.class=com.teamdev.jxbrowser.chromium.swing.internal.Native, META-INF/versions/9/com/teamdev/jxbrowser/chromium/internal/X509CertificateFactory.class=com.teamdev.jxbrowser.chromium.internal.X509CertificateFactory, META-INF/versions/9/com/teamdev/jxbrowser/chromium/swing/internal/AWTHelper$InstanceHolder.class=com.teamdev.jxbrowser.chromium.swing.internal.AWTHelper$InstanceHolder, META-INF/versions/9/com/teamdev/jxbrowser/chromium/javafx/internal/Native.class=com.teamdev.jxbrowser.chromium.javafx.internal.Native, META-INF/versions/9/com/teamdev/jxbrowser/chromium/internal/OS.class=com.teamdev.jxbrowser.chromium.internal.OS}
I have cleared my maven cache and tried versions 6.18-6.20 but I can only build with 6.17 and below. My license file claims to work for versions 6.X, so I would assume that is not the issue.
Thanks!
Starting from the version 6.18, JxBrowser provides multi-release jars, so it is able to work with both Java 8 and Java 9. And it seems that the maven used to build the application does not support the MR-JAR's, so it generates a build error. So you need to upgrade Maven version.
we have a Jenkins job which is/was configured to use JDK7. Upon inspecting the logs, i noticed following ERRORs:
ERROR: Invalid project setup: jenkins/security/MasterToSlaveCallable : Unsupported major.minor version 52.0
ERROR: [JENKINS-18403][JENKINS-28294] JDK 'JDK 1.7.0_45' not supported to run Maven projects.
ERROR: Maven projects have to be launched with a Java version greater or equal to the minimum version required by the master.
ERROR: Use the Maven JDK Toolchains (plugin) to build your maven project with an older JDK.
ERROR: Retrying with slave Java and setting compile/test properties to point to /usr/java/jdk1.7.0_45/.
After some googling it seems that there is some interaction between the Job and Jenkins itself. Since Jenkins is started with JDK8 and the Job with JDK7 it seems to produce this ERROR. The build is OK, because Jenkins then proceeds to build with JDK8. But we actually want this built with 1.7.
So the question is:
If we start Jenkins with JDK8, how can i get the Jobs to compile with JDK7 without this error?
this is apparently a technical limitation of Jenkins plugin Maven Integration.
Because java serialized classes are exchanged between Jenkins master and Maven Jobs it is required that the JVM used to launch Maven is superior or equal to the version of Java for which Jenkins Master is built for.
I suspect that you have a Jenkins version too recent, requiring a JDK version >= 8.
As the required version was 7, you could either use java 7 or 8 - or even 9. So your build succeeded with Java7, even if your Jenkins was started with Java8.
You can either downgrade your Jenkins installation, or move all your builds to Java8.
Cheers
For using Java 1.7 on Jenkins >= 2.54 you need to transform the Maven project in a Free-style project. In the Free-style project you can specify the JDK version. This is because starting from version 2.54, Jenkins was upgraded to use Java 8.
From Jenkins release notes:
Using the Maven project type with Java 7
Users with jobs configured with the "Maven project" type may not be
able to use Java 7 for their Maven jobs. The correct behavior is not
guaranteed so proceed at your own risk. The Maven Project uses Jenkins
Remoting to establish "interceptors" within the Maven executable.
Because of this, Maven uses Remoting and other Jenkins core classes,
and this behavior may break an update
You can also see here how to create a Free-style project
As you might probably know Jenkins >= 2.54 requires Java >= 8 thus Maven jobs must be launched with Java >= 8
Besides that the Error message is guiding you with:
Use the Maven JDK Toolchains (plugin) to build your maven project...
Using that plugin would probably help you to run your jenkins job using Java 8 and also compile your project files using Java 7.
I resolved my problem this way some years ago.
You can see more details on this Answer.
The interaction is based on that Jenkins will try to be informed about finishing single modules and if there are artifacts being created and some other stuff. This is handled by a EventSpy implementation in Jenkins. That can cause issues like this.
Im trying to compile some code in I'm using Intellij Ultimate 13.1.4, but I get the following error and I have no idea what it means:
Information:Using javac 1.7.0_55 to compile java sources
Information:java: Errors occurred while compiling module 'Example'
Information:Compilation completed with 1 error and 0 warnings in 3 sec
Information:1 error
Information:0 warnings
Error:java: invalid source release: 8
My guess is that its something related to Java 8 vs Java 7, but I have no idea what specifically. I've tried to Google around for this message, but they either talk about javac or target release, so it doesn't exactly seem to apply.
I had the same issue when "downgrading" a project from Java 8 to Java 6. The reason was that it was not changed at all places in IntelliJ.
In IntelliJ 13.1.4 I had to change Java and SDK version on the following places not to get this error:
File -> Project Structure -> Project Settings
File ->
Project Structure -> Module Settings -> Tab: Sources: Language Level
File -> Project
Structure -> Module Settings -> Tab: Dependencies: Module SDK
File -> Settings -> Compiler -> Java Compiler -> Target bytecode
version
The last bullet was the one that was not updated in my case. Once I changed this, the error disappeared.
Check your pom.xml first (if you have one)
Check your module's JDK dependancy. Make sure that it is 1.8
To do this,go to Project Structure -> SDK's
Add the path to where you have stored 1.8 (jdk1.8.0_45.jdk in my case)
Apply the changes
Now, go to Project Structure ->Modules
Change the Module SDK to 1.8
Apply the changes
Voila! You're done
For Gradle users having this issues, if nothing above helps this is what solved my problem - apply this declarations in your build.gradle files:
targetCompatibility = 1.6 //or 1.7;1.8 and so on
sourceCompatibility = 1.6 //or 1.7;1.8 and so on
Problem solved!
Change in pom.xml 1.6 to 1.8
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
If you are using Gradle as a build tool and you get this error when executing a Gradle task i.e TomcatRun take a look to my other answer to the same question
javac: invalid target release: 1.8
It can be simply overcome by setting on Project Structure. You just need to select the right path for related version of JDK. Select new on dependencies tab, and choose the path. It's done!
Andreas Lundgren's answer worked and I was able to compile and run my app.
However, when I tried to run the project's associated JUnit tests I received the same error. Running
gradle -version
from Windows command prompt showed that gradle was still picking up the incorrect jdk. To fix it I had to set the JAVA_HOME environment variable to point to the correct jdk and restart IntelliJ.
I checked all above said project version, module version, project bytecode version, target bytecode version settings in IntelliJ Idea, but all were the same as I scratched.
I face this error Error:java: invalid source release: 1.8 in IntelliJ Idea 2017.2.6 because I upgraded the dependency version Maven pom file, which(dependency) were supposed to build for JDK 1.8 application and I were building my application on and with maven compiler source and target JDK 1.7.
Hence I again downgrade the dependency version to earlier one in Maven pom, and the error gone after project Rebuild Module 'xyz_project'.
If You Get This ERROR: Error:java: invalid source release: 12
Information:java: Errors occurred while compiling module 'IdeaProjects'
Information:javac 1.8.0_211 was used to compile java sources
Information:Module "IdeaProjects" was fully rebuilt due to project configuration/dependencies changes
Information:7/12/2021 8:21 PM - Build completed with 1 error and 0 warnings in 6 s 323 ms
Error:java: invalid source release: 12
THEN
Select Your Previous Version Project
In My side :
FINISHED
If you Get SOlution of Your IDE then Message Me www.betechnical.tech
or amankushwaha9918#gmaill.com
For Grails users, apply these declarations in your BuildConfig.groovy file:
grails.project.target.level = 1.6 //or 1.7;1.8 and so on
grails.project.source.level = 1.6 //or 1.7;1.8 and so on
You need to click to the project
Open Module Settings and change the path of your JDK, if in the file POM you use jdk 1.8, configure jdk 1.8 with correct path.
I add one more path unmentioned in this answer https://stackoverflow.com/a/26009627/4609353
but very important is Edit Configurations
I tried out all the steps mentioned in here https://stackoverflow.com/a/26009627/2058104, but the 4th point has now changed. You need to go to Preferences -> Build, Execution, Deployment -> Compiler -> Java Compiler
In there, as shown in below figure, you need to change the "Target bytecode version". Although, I changed it to 8 (since I needed to downgrade to Java 8), it was giving the same error, over and over. Therefore, try to remove the existing entry (in this table) and add it again. This worked for me.
On the other hand, clean the project and try to run again.
I had the same issue the solution for me was to change my java version in the pom.xml file.
I changed it from 11 to 8.
Lots of good answers.
For those using the (almost) latest version of Intellij, at the time of writing, what can be said, is that the project JDK can be at a higher level, than that of the module.
In fact without it, Maven will have to be rolled back to an older version.
Therefore with the following version of Intellij:
One should not change the project level JDK and therefore be able to leverage the Maven or Gradle settings when building, but when running Maven or running Gradle using a more modern version of the JDK.
If you lower your project level JDK from say JKD8 to JDK6, Maven or Gradle will not run.
Keeping your module at a lower level JDK-wise will enable you to build it to that version, if you use the Module rebuild or build options; using the menu options for rebuilding the project will complain wit "Invalid source release:8...".
As Andreas mentioned all about:
Error:java: invalid source release: 8 in IntelliJ
Error:java: invalid source release: 13 in IntelliJ
Error:java: invalid source release: 14 in IntelliJ...
OR whatever version you are using in Java...
The problem will exist if you do not have it matching inside the below code:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
This 1.8 in my case, must be matching on your device through MAVEN project library, settings, preferences, project setting and SDK.
I was recently facing the same problem.
This Error was showing on my screen after running my project main file.
Error:java: invalid source release: 11
Follow the steps to resolve this error
File->Project Structure -> Project
Click New button under Project SDK: Add the latest SDK and Click OK.
After running You will see error is resolved..
In my case the nuance was that I got a invalid source release 11 (instead of OP's 8). I tried all the solutions above
gradle jvm version , java compilter bytecode version, module language.
I set all the above to java 8 (or 1.8) as that is the library I have on my machine.
The issue was that the build.gradle file had
sourceCompatibility = '11'
Changed this to 8 and it stopped throwing 'compile failed invalid release 11' error
solution reference: github forum