1

I'm trying to import a project into Intellij using Solus and I'm having a bit of an issue with Gradle being able to find the correct Java location. I get this error when I try to sync:

Cause: error=2, No such file or directory

Which, when going through Intellij's logs, is caused by this:

Caused by: java.io.IOException: Cannot run program "/opt/jdk1.8.0_221/bin/java" (in directory "/home/me"): error=2, No such file or directory

For some reason Gradle is looking in my home directory for my $JAVA_HOME location, and I have no idea why or how to point it to the right destination. I have a symlink between /opt/jdk1.8.0_221 and usr/bin/java, and when I run echo $JAVA_HOME I get this output:

~ $ echo $JAVA_HOME
/usr/bin/java

Is there something I'm doing incorrectly with setting up Java on Solus? Or am I missing some Gradle setting?

Phil
  • 157,677
  • 23
  • 242
  • 245
Shan
  • 541
  • 3
  • 11
  • Your `$JAVA_HOME` should point to a directory. That directory should contain `bin/java`. It looks like that's your main problem – Phil Aug 06 '19 at 01:39
  • `which java` returns `/usr/bin/java`, I ran `export $JAVA_HOME="/usr/"` instead and still no dice. – Shan Aug 06 '19 at 03:17
  • Does `/opt/jdk1.8.0_221` exist? Have you installed the JDK as per [these instructions](https://getsol.us/articles/software/java/en/#jdk)? – Phil Aug 06 '19 at 03:34
  • Yes, there is a symlink to /opt/jdk1.8.0_221. `ls -la /usr/bin/java` confirms it. I did follow their guide on how to install it. – Shan Aug 06 '19 at 04:00
  • `lrwxrwxrwx 1 root root 26 Aug 5 12:41 /usr/bin/java -> /opt/jdk1.8.0_221/bin/java` this is the output of `ls -la /usr/bin/java` – Shan Aug 06 '19 at 04:09
  • Yes, `/opt/jdk1.8.0_221` is full and complete, has all content. `echo $JAVA_HOME` returns `/opt/jdk1.8.0_221`. Still getting the same error. – Shan Aug 06 '19 at 04:13
  • Very strange. What happens if you execute `/opt/jdk1.8.0_221/bin/java -version`? How about just `java -version`? In IntelliJ, you typically don't have to worry about `$JAVA_HOME` as you configure the Java installation to use under _"Project SDK"_ in Project Settings – Phil Aug 06 '19 at 04:17
  • Both yield `no such file or directory`, which has me *very* confused because I can navigate to /opt/jdk1.8.0_221/bin and see the java file in there. Running `/opt/jdk1.8.0_221/bin/java -version` returns `/opt/jdk1.8.0_221/bin/java: No such file or directory` and `java -version` returns `/usr/bin/java: No such file or directory`. Hmm.... – Shan Aug 06 '19 at 04:25
  • Yeah, this is why I generally have no troubles with this in Intellij. I can't even sync the project from VCS at all, as Gradle is having java issues. – Shan Aug 06 '19 at 04:26
  • This is the point where you start checking **very carefully** for typos in your directory names. Not sure if I can offer any more advice. Perhaps you could add some screenshots from `ls -la /opt/jdk1.8.0_221` and `ls -la /opt/jdk1.8.0_221/bin` (you can paste images directly into the [question editor](https://stackoverflow.com/posts/57367705/edit)) – Phil Aug 06 '19 at 04:28
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/197532/discussion-between-phil-and-shan). – Phil Aug 06 '19 at 04:42

1 Answers1

0

Not a true solution, but I just ended up reinstalling Solus and using SDKMan for managing my java installs. Everything is okay now!

Shan
  • 541
  • 3
  • 11