Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 814
user584910 Avatar asked Dec 21 '13 04:12

user584910


4 Answers

Install a JDK

sudo apt-get install openjdk-7-jdk

EDITED: initial answer had package for jre (not jdk)

like image 68
stevedbrown Avatar answered Nov 19 '22 19:11

stevedbrown


None of these worked on my Ubuntu, really. Turns out, there is something like
/usr/lib/jvm/default-java, which is a symbolic link to installed version of java.

The funny thing, this was pointing out to /usr/lib/jvm/java-7-openjdk-i386 (the JDK!), but JAVA_HOME pointed to completely different location - the location where I have my current, up-to-date JDK8 installation.

I simply updated the symlink to point to correct location, but it is likely to be overridden with an update of OpenJDK7... I guess I have to get rid of OpenJDK then.

like image 44
Paweł Dyda Avatar answered Nov 19 '22 18:11

Paweł Dyda


It was a problem with an environment variable. After correcting the java_home environment variable in etc/environment and restarting ubuntu, now it runs ok. Thanks for the guidance.

like image 3
user584910 Avatar answered Nov 19 '22 19:11

user584910


I was facing the same issue, after seeing this post, I tried doing

gradle -v
java -version
javac -version

javac failed. However, ubuntu prompted me to install javac with the following message

21:52:17->javac
The program 'javac' can be found in the following packages:
* default-jdk
* ecj
* gcj-4.8-jdk
* openjdk-7-jdk
* gcj-4.6-jdk
* openjdk-6-jdk
Try: sudo apt-get install <selected package>

After installing javac using openjdk-7-jdk and adding the following 2 lines to my bashrc, gradle started working

JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64/jre"
PATH="$PATH:$JAVA_HOME/bin"

Here, /usr/lib/jvm/java-7-openjdk-amd64/jre is the directory containing java binary found by doing which java

like image 2
Max Jindal Avatar answered Nov 19 '22 17:11

Max Jindal