Hot questions for Using Ubuntu in gradle
I'm trying to install gradle via the gvm command
'$ gvm i gradle', but I get a message with the offline mode.
(Any installation fail with the following message)
➜ ~ ➜ ~ ➜ ~ gvm i gradle GVM can't reach the internet so going offline. Re-enable online with: $ gvm offline disable ==== BROADCAST ============================================= OFFLINE MODE ENABLED! Some functionality is now disabled. ============================================================ This command is not available in offline mode. ➜ ~ ➜ ~ ➜ ~ gvm offline disable Online mode re-enabled! ➜ ~ ➜ ~ ➜ ~ gvm i gradle GVM can't reach the internet so going offline. Re-enable online with: $ gvm offline disable ==== BROADCAST ============================================= OFFLINE MODE ENABLED! Some functionality is now disabled. ============================================================ This command is not available in offline mode.
Additional info: The proxy has been configured.
➜ ~ ➜ ~ ➜ ~ ping gvmtool.net PING gvmtool.net (22.214.171.124) 56(84) bytes of data. 64 bytes from pages.github.com (126.96.36.199): icmp_seq=1 ttl=50 time=150 ms 64 bytes from pages.github.com (188.8.131.52): icmp_seq=2 ttl=50 time=151 ms 64 bytes from pages.github.com (184.108.40.206): icmp_seq=3 ttl=50 time=159 ms 64 bytes from pages.github.com (220.127.116.11): icmp_seq=4 ttl=50 time=155 ms 64 bytes from pages.github.com (18.104.22.168): icmp_seq=5 ttl=50 time=151 ms ^C --- gvmtool.net ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4005ms rtt min/avg/max/mdev = 150.383/153.800/159.585/3.507 ms
In case you come here half a year later: gvm is gone, it's now "sdkman!".
i needed to install al my tools and could remove ~/.gvm/
I'm unable to build my project using Java 11 and Gradle 5. I receive the following error trying to build:
$ gradle clean build > Task :compileJava FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileJava'. > Could not target platform: 'Java SE 11' using tool chain: 'JDK 10 (1.10)'.
Why does Gradle think I'm using JDK 10? My
$JAVA_HOME is set to
/usr/lib/jvm/java-1.11.0-openjdk-amd64/, which is the Linux OpenJDK build for Java 11 (found here https://jdk.java.net/11/). I'm using Gradle 5, but this error also occurred using 4.10.2.
Below are the relevant parts of my
apply plugin: 'java' sourceCompatibility = 11
I've also tried using
1.11 for source compatibility but this also fails with the same error.
The issue was unique to Ubuntu 18. The "JDK11" that is in
apt is actually JDK10 with backported JDK11 security updates. That's fairly confusing, so there is an open bug report with Ubuntu. See also this post on the AskUbuntu stack exchange.
To resolve the issue you have to manually set your system to use an actual JDK11. I did something similar to this guide to fix it.
How can I gradle my hello.java project? Right now I get the error message "Cannot find System Java Compiler". However, for me everything seems fine configured on this Ubuntu 14:
user:~/program/java/src/main/java$ javac hello.java user:~/program/java/src/main/java$ ls hello.class hello.java user:~/program/java/src/main/java$ java hello Hello World! user:~/program/java/src/main/java$ cd ../../../ user:~/program/java$ ls build build.gradle src user:~/program/java$ gradle build :compileJava FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileJava'. > Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory. * Try: ... BUILD FAILED
My system configuration:
user:~/program/java$ javac -version javac 1.7.0_72 user:~/program/java$ java -version java version "1.7.0_65" OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-0ubuntu0.14.04.1) OpenJDK Server VM (build 24.65-b04, mixed mode) suser:~/program/java$ echo "$JAVA_HOME" /usr/lib/jvm/java-1.7.0-openjdk-i386 user:~/program/java$ ls -l /etc/alternatives/java lrwxrwxrwx 1 root root 41 Jan 10 18:29 /etc/alternatives/java -> /usr/lib/jvm/java-7-openjdk-i386/bin/java
JAVA_HOME is defined in /etc/environment (was restarted) and also in the $HOME/.bashrc.
So, I think I did the things mentioned in this post. The hints there are similar to most hints I found googling.
Due to Invisible Arrows answer I changed $JAVA_HOME to /usr/lib/jvm/java-7-openjdk-i386
user:~/program/java$ echo "$JAVA_HOME" /usr/lib/jvm/java-7-openjdk-i386
Still the same error.
Following Invisible Arrows hint, I did a complete uninstallation of my java packages. Who, however, follows this should know, that the best voted answer there removes many packages you have to reinstall later.
After removing all java footprints I reinstalled java 7 jdk and gradle with
sudo apt-get install openjdk-7-jdk gradle
and now it works.
I use IntelliJ IDEA 2016.2.4 together with Gradle. When creating an empty project and adding a simple class together with a test class, the project builds fine when running
build target through Gradle, but IntelliJ doesn't see e.g.
@Test annotation for JUnit which is included in dependencies by default.
When hovering over the "missing" class, IntelliJ offers me to add JUnit4 to classpath. After doing this, nothing changes.
I tried invalidating caches and restarting - no success.
Under "External Libraries", there is "Gradle: junit:junit:4.11", and the project builds fine, so I presume it's an issue with syntax highlighting and autocompletion.
I'm not sure if it matters, but in
build.gradle the line that adds a dependency on JUnit (
testCompile group: 'junit', name: 'junit', version: '4.11') is highlighted with a comment:
'testCompile' cannot be applied to '(['group':java.lang.String, 'name':java.lang.String,...])' This inspection reports assignments with incompatible types
It works fine for other dependencies I tried, i.e. there's no warning like this. But IntelliJ still doesn't see their classes.
These are my first steps with Gradle, so maybe something is still not configured. Does anyone have an idea what might be wrong?
The cleaner way would be to Invalidate Caches / Restart. You can find this option in File menu.
Intellij Idea uses iml files to resolves class path. There are good chances its not correct.