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??
Related
Git clone legacy java project
gradle
------------------------------------------------------------
Gradle 6.1
------------------------------------------------------------
Build time: 2020-01-15 23:56:46 UTC
Revision: 539d277fdba571ebcc9617a34329c83d7d2b259e
Kotlin: 1.3.61
Groovy: 2.5.8
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 16.0.1 (AdoptOpenJDK 16.0.1+9)
OS: Mac OS X 10.16 x86_64
java
/usr/local/opt/openjdk#8/bin/java -version
openjdk version "1.8.0_362"
OpenJDK Runtime Environment (build 1.8.0_362-bre_2023_01_22_03_30-b00)
OpenJDK 64-Bit Server VM (build 25.362-b00, mixed mode)
gradle.properties
org.gradle.java.home=/usr/local/opt/openjdk#8
build.gradle
sourceCompatibility = "1.8"
try build
./gradle build
return error
The newly created daemon process has a different context than expected.
It won't be possible to reconnect to this daemon. Context mismatch:
Java home is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=/usr/local/opt/openjdk#8,daemonRegistryDir=/Users/user123/.gradle/daemon,pid=57082,idleTimeout=null,priority=NORMAL,daemonOpts=-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=UTF-8,-Duser.country=RU,-Duser.language=ru,-Duser.variant]
Actual: DefaultDaemonContext[uid=56ee62b0-08e3-4c19-bf54-73a5123254c1,javaHome=/usr/local/Cellar/openjdk#8/1.8.0+362/libexec/openjdk.jdk/Contents/Home,daemonRegistryDir=/Users/user123/.gradle/daemon,pid=57098,idleTimeout=10800000,priority=NORMAL,daemonOpts=-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=UTF-8,-Duser.country=RU,-Duser.language=ru,-Duser.variant]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
How solve this problem?
I can compiling the project from intellij but I can not compile from terminal(iTerm)
I am getting this error:
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
mvn -v:
Apache Maven 3.5.2
Maven home: /Users/myusername/developer_tools/apache-maven-3.5.2
Java version: 1.8.0_202, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre
echo $JAVA_HOME:
/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
java -version:
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
this is my .zshrc file and maven and java paths
open -e .zshrc
export M2_HOME=/Users/myusername/developer_tools/apache-maven-3.5.2
export PATH=${M2_HOME}/bin:${PATH}
export PATH
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
When I run mvn -v java home path is /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre is it related with this? why does jre appear here?
This was my output of gradle -v (in a project using the wrapper):
$ ./gradlew -v
------------------------------------------------------------
Gradle 5.0
------------------------------------------------------------
Build time: 2018-11-26 11:48:43 UTC
Revision: 7fc6e5abf2fc5fe0824aec8a0f5462664dbcd987
Kotlin DSL: 1.0.4
Kotlin: 1.3.10
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 11.0.1 (Oracle Corporation 11.0.1+13-LTS)
OS: Linux 3.10.0-862.11.6.el7.x86_64 amd64
See especially this line:
JVM: 11.0.1 (Oracle Corporation 11.0.1+13-LTS)
I was wishing to switch to OpenJDK 11. So select it as you can see below:
# alternatives --config java
There are 4 programs which provide 'java'.
Selection Command
-----------------------------------------------
* 1 /usr/java/jdk-11.0.1/bin/java
+ 2 /usr/local/jdk-11.0.1/bin/java
3 /usr/java/jre1.8.0_191-i586/bin/java
4 /usr/java/jdk1.8.0_191-amd64/jre/bin/java
Enter to keep the current selection[+], or type selection number: 2
# java -version
openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
But there is no difference in gradle -v output. So I searched the web and find some ways (see here):
Editing gradle.properties file
Using -Dorg.gradle.java.home command line option
Editing build.gradle file
I used the first two ways. Both worked (to test I switched to JDK 8 and then run build task. The task failed due to some new features in my codes that aren't supported by Java 8). But the result of gradle -v remained unchanged still! Even using the second way:
# ./gradlew -Dorg.gradle.java.home=/usr/java/jdk1.8.0_191-amd64 -v
------------------------------------------------------------
Gradle 5.0
------------------------------------------------------------
Build time: 2018-11-26 11:48:43 UTC
Revision: 7fc6e5abf2fc5fe0824aec8a0f5462664dbcd987
Kotlin DSL: 1.0.4
Kotlin: 1.3.10
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 11.0.1 (Oracle Corporation 11.0.1+13-LTS)
OS: Linux 3.10.0-862.11.6.el7.x86_64 amd64
So the question is how to check which JDK version is used by Gradle during build process?
You can add a task that prints what you need when executed (Kotlin DSL):
tasks {
val j by creating {
doLast {
println(System.getProperty("java.home"))
}
}
}
Groovy DSL:
tasks.register("j") {
doLast {
println System.getProperty("java.home")
}
}
Then executing ./gradlew j:
/usr/lib/jvm/java-8-openjdk/jre
Why could gradlew use another JVM? Take a look at this script and you'll see that it uses JAVA_HOME variable to search for JVM. So probably the version from your PATH is not the same, that JAVA_HOME is pointing to.
I find an alternative way (except #madhead answer) just for when you use a Gradle daemon:
First, find PID of daemon by running gradlew --status (see here for more information). Sample output:
PID STATUS INFO
11432 IDLE 5.0
Only Daemons for the current Gradle version are displayed. See https://docs.gradle.org/5.0/userguide/gradle_daemon.html#sec:status
Then use PID to find which JDK is used:
ll /proc/<PID>/exe
Sample output:
lrwxrwxrwx. 1 0xy 0xy 0 Jan 5 04:03 /proc/11432/exe -> /usr/local/jdk-11.0.1/bin/java
On Windows:
> wmic process where "processId=<PID>" get Name, ProcessID, ExecutablePath
Sample output:
ExecutablePath Name ProcessId
C:\Program Files\Java\openjdk-11.0.1\bin\java.exe java.exe 11432
$ 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?
I use Android Studio and recently got the error:
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
compileSdkVersion 'android-24' requires JDK 1.8 or later to compile.
But I have JDK 1.8 installed already:
:\Users..>java -version
java version "1.8.0_91" Java(TM) SE Runtime
Environment (build 1.8.0_91-b15) Java HotSpot(TM) 64-Bit Server VM
(build 25.91-b15, mixed mode)
How to fix it? Thanks
In Android Studio open:
File > Project Structure > see if JDK location points to your JDK 1.8 directory.
Note: you can use compileSdkVersion 24
I have a same problem for days. I found a solution which worked from me on Windows. (I also set environment variables, but don't know whether it's needed.)
Add these lines to build.gradle file:
android {
...
defaultConfig {
...
jackOptions {
enabled true
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
Source: https://code.google.com/p/android/issues/detail?id=203850
I installed latest jdk but it was using the older one until I did this:
app rt-click >> module settings >> sdk location >> (old jdk path)
Replace the old JDK path with your new jdk path.
Works like a charm now :)
Just an FYI I had this error with an Ionic project. All the commands came back pointing to the correct JDK and JAVA_HOME was set correctly.
There was an entry in my PATH to JDK 1.7\bin, replacing that with the 1.8\bin fixed it for me.
I was also running into the same issue from the command line on my Mac, but the answer was that JAVA_HOME was getting overridden. To track down where it is getting overridden first check java from the command line:
$ java -version
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
Then check which version of Java that Gradle is using:
$ gradle -version
------------------------------------------------------------
Gradle 2.13
------------------------------------------------------------
Build time: 2016-04-25 04:10:10 UTC
Build number: none
Revision: 3b427b1481e46232107303c90be7b05079b05b1c
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_92 (Oracle Corporation 25.92-b14)
OS: Mac OS X 10.11.5 x86_64
At this point, I still hadn't found the source of the problem. Did a little digging, and found that it was indeed overridden in my gradle.properties file even though it was showing Java 8 when I executed gradle -version:
org.gradle.daemon=true
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home
org.gradle.jvmargs=-XX:MaxPermSize=512m -XX:-UseSplitVerifier -Xms512m -Xmx6144m
To fix, I just deleted the java.home line from gradle.properties. Hopefully this helps if anyone else is running into the same issue from the command line.
In Android Studio open:
File > Project Structure > SDK Location > Select jdk1.8.0_101.jdk > Home
I was also running into the same issue from the command line on my Windows, it shows the same hint.
Error:Execution failed for task ':app:compileDebugJavaWithJavac'. `compileSdkVersion 'android-24' requires JDK 1.8 or later to compile.`
check JDK location in Project Structure.
In Android Studio open: File > Project Structure > see if JDK location
points to your JDK 1.8 directory.
It should look like
JDK Location
C:\Program Files\Java\jdk1.8.0_91
I already set the correct location to JDK.
check the java version
D:\AndroidSelfTrainingProject\CustomBuildIdDemo>java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
check the gradle version
.D:\AndroidSelfTrainingProject\CustomBuildIdDemo>gradle -v
------------------------------------------------------------
Gradle 2.10
------------------------------------------------------------
Build time: 2015-12-21 21:15:04 UTC
Build number: none
Revision: 276bdcded730f53aa8c11b479986aafa58e124a6
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_79 (Oracle Corporation 24.79-b02)
OS: Windows 7 6.1 amd64
JVM version should be 1.8.
To fix it, we can add in the gradle.property
In gradle.properties in the .gradle directory in your HOME_DIRECTORY set org.gradle.java.home=/path_to_jdk_directory. As for me, it is like:
org.gradle.java.home=C:/Program Files/Java/jdk1.8.0_91
To verify if it is set right, we can make a gradle build task.
D:\AndroidSelfTrainingProject\CustomBuildIdDemo>gradle build
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon
: https://docs.gradle.org/2.10/userguide/gradle_daemon.html.
To run dex in process, the Gradle daemon needs a larger heap.
It currently has approximately 910 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB.
To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html
On Windows 10, I first checked Project Structure and it pointed to an old 1.7 jdk. I closed Android Studio then renamed the old jdks (and jre libraries for consistency) leaving the newest 1.8 library alone. When I restarted Android Studio and attempted to build the application it asked me for the Java JDK library and I gave the path to the newest 1.8 JDK library. On my system it was C:\Program Files\Java\jdk1.8.0_112.