Amber
Amber

Reputation: 944

Linux- javac Command Not Found

I use puTTy to connect to a remote server running Linux. When I run

abc@myName((/home/myName)$java -version

I get the following

java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

Then I used readlink -f $(which java) to find the location of the java command and I got the location as /opt/jdk1.7.0_80/bin/java.

Now I navigated to this location and listed the files

abc@myName(/opt/jdk1.7.0_80/bin)$ls
appletviewer  idlj       javac           javap         jconsole  jinfo    jps         jstat      native2ascii  rmic         serialver   wsgen
apt           jar        javadoc         java-rmi.cgi  jcontrol  jmap     jrunscript  jstatd     orbd          rmid         servertool  wsimport
ControlPanel  jarsigner  javafxpackager  javaws        jdb       jmc      jsadebugd   jvisualvm  pack200       rmiregistry  tnameserv   xjc
extcheck      java       javah           jcmd          jhat      jmc.ini  jstack      keytool    policytool    schemagen    unpack200

Then I tried the following

abc@myName(/opt/jdk1.7.0_80/bin)$javac

And got

-bash: javac: command not found

Could someone help me with this?

Upvotes: 0

Views: 22906

Answers (3)

JacobTheKnitter
JacobTheKnitter

Reputation: 483

In terminal, type the command javac -version

Does it yield the following message?

The command «javac» was not found, but it can be installed with: 

apt install default-jdk            
apt install openjdk-11-jdk-headless
apt install ecj                    
apt install openjdk-8-jdk-headless

If so, use apt install default-jdk and javac will be working again.

Upvotes: 3

FRED WILLIAMS ASSAMOI
FRED WILLIAMS ASSAMOI

Reputation: 96

This is a $PATH issue. $PATH is an environment variable that contains a list of directories to search when looking for an executable

Try to exceute this command:

export PATH=/opt/jdk1.7.0_80/bin:$PATH

Upvotes: 2

Elliott Frisch
Elliott Frisch

Reputation: 201409

The JDK folder you specified is not in your PATH. The current directory is not in your PATH either. Option 1.

cd /opt/jdk1.7.0_80/bin
./javac

That is using the local path.

Option 2.

/opt/jdk1.7.0_80/bin/javac

That is using the full path.

Option 3.

export PATH=$PATH:/opt/jdk1.7.0_80/bin
javac

That is adding the folder to your PATH.

Upvotes: 4

Related Questions