Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javac command not working in linux environment

Tags:

java

linux

jvm

I had successfully installed java on my linux system. When I ran a hello world test sample from desktop it ran successfully, but then after few days when I again tried to run it from terminal using javac command it gave me following response:

The program 'javac' can be found in the following packages:
 * default-jdk
 * ecj
 * gcj-5-jdk
 * openjdk-8-jdk-headless
 * gcj-4.8-jdk
 * gcj-4.9-jdk
 * openjdk-9-jdk-headless
Try: sudo apt install <selected package>

When I test my JAVA_HOME env. variable using echo $JAVA_HOME its showing: /usr/lib/jvm/java-8-openjdk-amd64

its also there with PATH variable. When I ran a which java command its showing: /usr/lib/jvm/java-8-openjdk-amd64/bin/java

and with command whereis java its showing: java: /usr/lib/jvm/java-8-openjdk-amd64/bin/java /usr/share/man/man1/java.1.gz

So, I don't understand the problem, as I, myself applied the env. variables, and its showing everything perfect, then why is not javac command running? can any one look into this problem.

like image 450
JPG Avatar asked Jan 29 '23 18:01

JPG


1 Answers

The core problem is that you do not have the Java Develoment Toolkit (which is different than the Java runtime) installed on your system. This means that utilities used to create Java programs (such as javac, jar, etc) are not on your system.

Thorbjørn Ravn Andersen gave the answer for Debian-family Linux systems, here's the answer for RedHat-family systems

yum install java-devel

or if you are on the latest Fedora

dnf install java-devel
like image 149
Edwin Buck Avatar answered Feb 01 '23 07:02

Edwin Buck