$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
$ gradle -version
Gradle 2.14
------------------------------------------------------------
Build time: 2016-06-14 07:16:37 UTC
Revision: cba5fea19f1e0c6a00cc904828a6ec4e11739abc
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.7.0_80 (Oracle Corporation 24.80-b11)
OS: Mac OS X 10.11.5 x86_64
I get this error when using Intellij to build a Gradle project
anyone know what's up with that? Should I use Java 8 instead of Java 7?
Related
I'm trying to migrate from Java 8 to Java 17 and I'm having some issues with Gradle.
Here is my java version:
openjdk 17.0.5 2022-10-18 LTS
OpenJDK Runtime Environment Corretto-17.0.5.8.1 (build 17.0.5+8-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.5.8.1 (build 17.0.5+8-LTS, mixed mode, sharing)
Here is my gradle version
------------------------------------------------------------
Gradle 7.5.1
------------------------------------------------------------
Build time: 2022-08-05 21:17:56 UTC
Revision: d1daa0cbf1a0103000b71484e1dbfe096e095918
Kotlin: 1.6.21
Groovy: 3.0.10
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 17.0.5 (Amazon.com Inc. 17.0.5+8-LTS)
OS: Windows 10 10.0 amd64
I'm also using Eclipse 2022-12 and when I try to get a list of tasks with the Gradle plugin, I get
Execution failed for task ':buildSrc:compileGroovyPlugins'.
> BUG! exception in phase 'semantic analysis' in source unit 'precompiled_ProjectbJavaConventions' Unsupported class file major version 63
Any idea of how to fix this...
Thanks!
I fixed the issue upgrading Gradle to 7.6
------------------------------------------------------------
Gradle 7.6
------------------------------------------------------------
Build time: 2022-11-25 13:35:10 UTC
Revision: daece9dbc5b79370cc8e4fd6fe4b2cd400e150a8
Kotlin: 1.7.10
Groovy: 3.0.13
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 17.0.5 (Amazon.com Inc. 17.0.5+8-LTS)
OS: Windows 10 10.0 amd64
When I'm calling mvn --version I get the following :
Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)
Maven home: /usr/local/Cellar/maven/3.8.2/libexec
Java version: 16.0.2, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk/16.0.2/libexec/openjdk.jdk/Contents/Home
Default locale: en_US, platform encoding: US-ASCII
OS name: "mac os x", version: "11.4", arch: "x86_64", family: "mac"
So I take the version 16 is used
But when I'm calling java -version :
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)
Here I have java11.
I found out that the mvn command (found using which mvn) is actually a bash script in which the JAVA_HOME variable is defined, so I do get how I'm landing into /usr/local/Cellar/openjdk/16.0.2/libexec/openjdk.jdk/Contents/Home when running maven.
But what is extremely confusing is the behaviour of java -version. java refers to an executable /usr/bin/java that is just lying there. And if I set the JAVA_HOME :
JAVA_HOME=/usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home
Then java -version returns :
openjdk version "16.0.2" 2021-07-20
OpenJDK Runtime Environment Homebrew (build 16.0.2+0)
OpenJDK 64-Bit Server VM Homebrew (build 16.0.2+0, mixed mode, sharing)
So it looks like the /usr/bin/java executable reads this variable and calls the corresponding "real" java exec...
But then, my paramount question is : when the JAVA_HOME variable isn't defined, how the heck is this /usr/bin/java executable figuring where is the openjdk in version 11 ?
The short answer is on macos /usr/bin/java is the same executable as /usr/libexec/java_home. See the manual page for java_home(1) which references a "default order."
I have some Java code that compiles on my Mac, but fails to compile on my Ubuntu machine. Specifically, when using the static of method of List, I get the error:
error: cannot find symbol
List<String> list2 = List.of("cat", "dog");
^
symbol: method of(String,String)
location: interface List
1 error
I thought perhaps this was an issue with the Java version. Sure enough, it was using only Java 8. However, I subsequently upgraded my Ubuntu machine to use Java 11 using OpenJDK, but I still get the same issue.
The output I get from running java -version on the Ubuntu machine is:
openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment (build 11.0.1+13-Ubuntu-3ubuntu116.04ppa1)
OpenJDK 64-Bit Server VM (build 11.0.1+13-Ubuntu-3ubuntu116.04ppa1, mixed mode, sharing)
The output I get from running java -version on the Mac machine is:
java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
For compilation, I am using Gradle version 5.2.1. I am using the Gradle wrapper, so both machines are using the same version of Gradle.
Here is the file that does not compile properly.
package mypackage;
import java.util.List;
import java.util.ArrayList;
public class App {
public static void main(String[] args) {
// No errors on both MacOS and Ubuntu
List<String> list1 = new ArrayList<>();
list1.add("cat");
System.out.println(list1);
// Fails to compile on Ubuntu
List<String> list2 = List.of("cat", "dog");
System.out.println(list2);
}
}
List.of() was introduced in Java 9. This indicates that your update from Java 8 to Java 11 wasn't successful.
Run ./gradlew -v to see which version of Java is resolved by Gradle:
------------------------------------------------------------
Gradle 5.3.1
------------------------------------------------------------
Build time: 2019-03-28 09:09:23 UTC
Revision: f2fae6ba563cfb772c8bc35d31e43c59a5b620c3
Kotlin: 1.3.21
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 11.0.2 (Oracle Corporation 11.0.2+9)
OS: Linux 4.15.0-47-generic amd64
Make sure you aren't using Gradle daemon started on Java 8 before updating to Java 11 and in build.gradle force Java 11 compatibility:
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
This one is completely beyond me. :-/
Will take any trouble shooting tips I can get.
* What went wrong:
Execution failed for task ':commons:stuf-widgets:compileJava'.
> com/sun/tools/javac/util/Log$PrefixKind
The above resulted from:
gradle clean;gradle build
Fix I tried:
compile files("${System.properties['java.home']}/../lib/tools.jar")
Got that from another question wherein a class that should have been in tools.jar was not loaded. Adding it changed nothing. I don't see anything special about the dependencies. Using --stacktrace --debug --info did not provide any additional clues other than as noted above. There is nothing special going on like JAXB or WSDL generation.
Environment:
me#mybox-me ~ $ java -version
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
me#mybox-me ~ $ which gradle
/####/#######/gradle/bin/gradle
me#mybox-me ~ $ which groovy
/####/#######/groovy/bin/groovy
gradle --version
------------------------------------------------------------
Gradle 2.8
------------------------------------------------------------
Build time: 2015-10-20 03:46:36 UTC
Build number: none
Revision: b463d7980c40d44c4657dc80025275b84a29e31f
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_66 (Oracle Corporation 25.66-b17)
OS: Linux 3.16.0-53-generic amd64
groovy -version
Groovy Version: 2.4.5 JVM: 1.8.0_66 Vendor: Oracle Corporation OS: Linux
Tho me a bone??
I just downloaded the linux 64 bit tar for eclipse mars. When I try and run the installer it gives me the following message
Version 1.6.0_31 of the JVM is not suitable for this product.
Version: 1.7 or greater is required.
I am on java version 1.8. See
$java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
Where does it get the 1.6 version of java?
.cshrc.mine
setenv $JAVA_HOME /path/to/Java8
setenv PATH /path/to/Java8/bin/:$PATH
Also
$ java -XshowSettings:properties -version
Property settings:
// Other props
java.runtime.name = Java(TM) SE Runtime Environment
java.runtime.version = 1.8.0_65-b17
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
Try specify the JDK/JRE path by adding the following two lines into the beginning of your eclipse.ini file:
-vm
[your-path-to-java-executable]
In your eclipse.ini file you should point to java8
-vm
/opt/jdk18025/bin/javaw.exe