Reputation: 1253
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.
Upvotes: 6
Views: 29466
Reputation: 1
dont worry here is your solution:) first, find where is JVM in your Linux
whereis jvm
in my case jvm in jvm: /usr/lib/jvm so now go to that directory look at the image and checkout
after coming here
root㉿kali)-[/usr/lib/jvm/java-17-openjdk-amd64/bin]
search ls command look in the image there is not a javac file present
┌──(root㉿kali)-[/usr/lib/jvm/java-17-openjdk-amd64/bin]
└─# apt-get install openjdk-17-jdk
try this if you are using OpenJDK-8 or any different kindly changes the number as your requirement. this command download everything now look what new things come
┌──(root㉿kali)-[/usr/lib/jvm/java-17-openjdk-amd64/bin]
└─# ls
jar javadoc jdb jhsdb jmap jrunscript jstatd
jarsigner javap jdeprscan jimage jmod jshell keytool
java jcmd jdeps jinfo jpackage jstack rmiregistry
javac jconsole jfr jlink jps jstat serialver
hurray all stuff is done , learn how to run java in terminal, create hello.java file in desktop, let compile using javac , then run though java ,
┌──(root㉿kali)-[~/Desktop/javac]
└─# javac hello.java
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
┌──(root㉿kali)-[~/Desktop/javac]
└─# java hello.java
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Hello World
Upvotes: 0
Reputation: 3551
Just my 5 cents. On CentOS 7 (assuming you want LTS Java 11):
sudo yum install java-11-openjdk-devel
Upvotes: 0
Reputation: 70909
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
Upvotes: 10
Reputation: 75376
Undo your environment settings and run sudo apt install openjdk-8-jdk
. javac should now be in your path.
Upvotes: 6
Reputation: 198
/usr/lib/jvm/java-8-openjdk-amd64/bin/java
is not an dir, its an excecuteable. try excecute the following to use javac:
/usr/lib/jvm/java-8-openjdk-amd64/bin/javac
or
/usr/lib/jvm/java-8-openjdk-amd64/bin/jstack
Upvotes: -1