Execution completed for task ': compileJava'. > Invalid source release: 1.7

I use:

  • gradle -2.3
  • javac -version = 1.7
  • jre = 1.7
  • regedit shows that it points to 1.7.

But I'm still getting below the error

Execution completed for task ': compileJava'. > invalid source release: 1.7

Please let me know how to fix this.

+6
source share
6 answers

You say you are working with Java 7, but are you really sure?

Because, as far as I know, this error occurs exactly when you use a source / target level that is not supported by the JVM, you use gradle with. Therefore, if I were to assume that I would say that gradle seems like your JDK does not support Java 7 (therefore its JDK is 6 or lower)

Maybe double check that

a) gradle itself works with JDK 7. If you start gradle from Eclipse using the STS gradle tool, it will use the standard workspace JRE to start gradle. Make sure that it is at least JDK 7. (Go to β€œWindows Preferences β†’ β†’ Java β†’ Installed JRE.” The checkmark JRE will work with gradle).

b) gradle may accidentally pick up another JDK to compile files if it finds a JAVA_HOME environment variable. So double check that it is not pointing to JDK 6 or lower.

+5
source

You can install the JDK version used by gradle for assembly by adding the gradle.properties file to the project. Add the following property:

org.gradle.java.home = <Path to the JDK you want to use for your project> 

I agree with the previous answer that you should also check that the JDK is consistent with the original compatibility.

+3
source

Try the following in your gradle assembly:

 apply plugin: 'java' sourceCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7 

If this does not work, provide the contents of your build.gradle.

+1
source

In my case, Gradle was working on the JRE instead of the JDK (wrong set of JAVA_HOME). By pointing my JAVA_HOME to the root of the JDK, the assembly is fixed. (Of course, if your PATH has% JAVA_HOME% \ bin)

Cause:

The JDK has javac to compile java, while the JRE does not.

0
source

Just a "bug" with 1.8 java

Solved: Findbugs showed me ΓΌ in the method name (not allowed in the gradient)

0
source

to check if $ JAVA_HOME really indicates the default value java # echo $JAVA_HOME / usr / lib / jvm / java -1.7.0-openjdk # java -version version "1.8.0_151" if it is offset as above to change $ JAVA_HOME in the / etc / profile file (or, alternatively, .profile / .bashprofile / in the user's home directory) specify JAVA_HOME = / usr / lib / jvm / java-1.8.0-openjdk BTW: decided to fix the invalid in Centos7 release 1.8

0
source

Source: https://habr.com/ru/post/987903/


All Articles