-1

I am using Linux aarch64 machine. I use miniconda3 and create a virtual environment in miniconda3. I want to install tensorflow using bazel. Therefore I first download the bazel zip file.

When I run the compile.sh file after extracting the zip file of "bazel", I got the following error

INFO: You can skip this first step by providing a path to the bazel binary as second argument:
INFO:    ./compile.sh compile /path/to/bazel
  Building Bazel from scratch
ERROR: Cannot determine JDK version, please set $JAVA_HOME.\n $JAVAC_VERSION is "javac 11.0.16"

When I search Java version , java --version I got this

openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Ubuntu-0ubuntu120.04, mixed mode)

May I know how can I solve the issue? When I check echo $JAVA_HOME", I got nothing. Do I also need to set JAVAC_VERSION? If yes, may I know how can I set both Java_home and javac_version? Thank you.

Susan
  • 431
  • 1
  • 4
  • 16
  • No help from me, just info. JAVA_HOME was a (cross-platform) requirement of the JDK, that now no longer holds. It seems bazel still uses it. Alternative java versions side-by-side: https://askubuntu.com/questions/315646/update-java-alternatives-vs-update-alternatives-config-java – Joop Eggen Aug 18 '22 at 09:39
  • @user16320675 yes and then there was also JDK_HOME. – Joop Eggen Aug 18 '22 at 11:08

3 Answers3

1

It seems like you didn't set JAVA_HOME environment variable

Please check here to manually setup environment variables.

Here you should set export JAVA_HOME=<java_path>

Phillip
  • 170
  • 4
  • May I know how to check which java_path my linux is using? – Susan Aug 18 '22 at 06:10
  • When I search java path in google, it shows ```export PATH=/usr/java/ bin:$PATH" But when I check /usr/ folder, there is no java folder. it has only ``` src, share, sbin, local , libexec, lib, include, games, bin folder``` – Susan Aug 18 '22 at 06:12
  • May this link work for you? https://unix.stackexchange.com/questions/21689/how-to-find-path-where-jdk-installed – Phillip Aug 18 '22 at 06:12
  • Hello Phillip, when I check ```which java```, it gives ```/usr/bin/java```. When I check ```whereis java```, it gives ```java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz```. May I know which java directory should I set for export JAVA_HOME? – Susan Aug 18 '22 at 06:24
  • Please run this command : `ls -l /etc/alternatives/java` And let me know the result. – Phillip Aug 18 '22 at 06:29
  • You should `export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64/bin/java` Did you try without quotes? – Phillip Aug 18 '22 at 06:44
  • ```lrwxrwxrwx 1 root root 43 Aug 18 11:47 /etc/alternatives/java -> /usr/lib/jvm/java-11-openjdk-arm64/bin/java``` When I ```export JAVA_HOME='/usr/bin/java'```, and compile the bazel's ./compile.sh, It gives ERROR: JAVA_HOME (/usr/bin/java) is not a path to a working JDK. I also tried with ```export JAVA_HOME='/usr/lib/jvm/java-11-openjdk-arm64/bin/java'```, and compile, it also give java_home is not a path to a working JDK – Susan Aug 18 '22 at 06:45
  • 1
    Without quotes ```export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64/bin/java``` also give the same error ```ERROR: JAVA_HOME (/usr/lib/jvm/java-11-openjdk-arm64/bin/java) is not a path to a working JDK. ``` – Susan Aug 18 '22 at 06:46
  • `export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64` should work. And please restart your OS. Otherwise, try this link: https://stackoverflow.com/questions/24641536/how-to-set-java-home-in-linux-for-all-users – Phillip Aug 18 '22 at 06:51
  • I tried both ```/usr/lib/jvm/java-11-openjdk-arm64``` and ```/usr/lib/jvm/java-11-openjdk-arm64/bin/java```. I also restarted the OS. I got the same issue. I want to know when ```export JAVA_HOME=``` is added, in the .bashrc file, how does it modify? Because when I check the .bashrc file, it does not modify anything/ – Susan Aug 18 '22 at 07:25
  • Did you try adding to .bashrc manually? – Phillip Aug 18 '22 at 07:32
  • No, I did not add manually to .bashrc. I check it but don't find export Java_Home line in the .bashrc. – Susan Aug 18 '22 at 07:34
  • Then please add it manually, restart your OS, and try again. – Phillip Aug 18 '22 at 07:37
  • Should I add ```export JAVA_HOME='/usr/lib/jvm/java-11-openjdk-arm64/bin/java'``` to the .bashrc file? – Susan Aug 18 '22 at 07:39
  • Without quotes. If it doesn't work, try with `export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64`. And please don't forget to restart your OS. – Phillip Aug 18 '22 at 07:42
  • Hello Phillip, with and without quotes, give the same issue after restarting OS. In the https://stackoverflow.com/questions/24641536/how-to-set-java-home-in-linux-for-all-users, ```export JAVA_HOME="path that you found" export PATH=$JAVA_HOME/bin:$PATH```. inside that "path that you found", should I give ```/usr/lib/jvm/java-11-openjdk-arm64``` or ```/usr/lib/jvm/java-11-openjdk-arm64/bin/java```? – Susan Aug 18 '22 at 07:46
  • Please try both of them. But I recommend the latter form. – Phillip Aug 18 '22 at 07:48
  • I got the same error after adding ```export JAVA_HOME="path that you found" export PATH=$JAVA_HOME/bin:$PATH``` to vim /etc/profile. – Susan Aug 18 '22 at 08:38
  • ```ERROR: JAVA_HOME (/usr/lib/jvm/java-11-openjdk-arm64/bin/java) is not a path to a working JDK.``` May I know is it related to the JAVA_HOME path is not the path for working JDK ? – Susan Aug 18 '22 at 08:41
0

Try to set up an Environment Variable. Google "how to install JDK 8." You can get better answers there

Sendi
  • 11
  • 2
0

Thank you @Philip for your input and advice.

The issue is solved by:

  1. ls -l /etc/alternatives/java gives etc/alternatives/java -> /usr/lib/jvm/java-11-openjdk-arm64/

  2. vim /etc/profile

  3. Press I

  4. Add

    export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64/bin/java
    
    export PATH=$JAVA_HOME/bin:$PATH
    
  5. Reboot the os. source /etc/profile

Susan
  • 431
  • 1
  • 4
  • 16