ubuntu Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) a

Viewed 13714

On ubuntu 12, I am trying to run example program of fuse-jna. I got below error message

syed@ubuntu:~/Downloads/fuse-jna-master/examples$ ./hellofs.sh ~/hellofs
: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:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

running java -version command shows me:

syed@ubuntu:~/Downloads/fuse-jna-master/examples$ java -version
java version "1.7.0_15"
OpenJDK Runtime Environment (IcedTea7 2.3.7) (7u15-2.3.7-0ubuntu1~12.10)
OpenJDK Client VM (build 23.7-b01, mixed mode, sharing)

output of javac -version:

syed@ubuntu:~/Downloads/fuse-jna-master/examples$ javac -version
javac 1.6.0_27

these are installed on my system, see the picture here

http://i40.tinypic.com/2hf2j4z.png

Please guide me to run this program on Ubuntu

7 Answers

For me the problem was I had JRE but not JDK. Earlier I used to have below output

$ java -version
java 18.0.1.1 2022-04-22
Java(TM) SE Runtime Environment (build 18.0.1.1+2-6)
Java HotSpot(TM) 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)

As soon I installed JDK my output changes as below

$ sudo apt install default-jre
$ java -version
openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.21.04)
OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.21.04, mixed mode, sharing)

This solved the problem. I also added last 2 lines to file etc/environment

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
JAVA_HOME="/usr/lib/jvm/jdk-18"
PATH="$PATH:$JAVA_HOME/bin"
Related