javac : command not found

2019-01-30 01:37发布

I have installed java in my CentOS release 5.5 machine using the command yum install java. But I am unable to compile a class using javac.

Do I need to install any other package?

I have tried to locate the javac executable but i am unable to locate it.

/usr/bin/java is linked as follows:
/usr/bin/java -> /etc/alternatives/java
/etc/alternatives/java -> /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java

I have seen the following output by yum list installed |grep java:

java-1.6.0-openjdk.x86_64              1:1.6.0.0-1.16.b17.el5          installed
tzdata-java.x86_64                     2011b-1.el5                     installed

7条回答
forever°为你锁心
2楼-- · 2019-01-30 02:20

I don't know exactly what yum install java will actually install. But to check for javac existence do:

> updatedb
> locate javac

preferably as root. If it's not there you've probably only installed the Java runtime (JRE) and not the Java Development Kit (JDK). You're best off getting this from the Oracle site: as the Linux repos may be slightly behind with latest versions and also they seem to only supply the open-jdk as opposed to the Oracle/Sun one, which I would prefer given the choice.

查看更多
该账号已被封号
3楼-- · 2019-01-30 02:20

install same version javac as your JRE yum install java-devel

查看更多
混吃等死
4楼-- · 2019-01-30 02:22

Worked for me with this command:

yum install java-devel
查看更多
Luminary・发光体
5楼-- · 2019-01-30 02:28

You installed the Java Runtime Environment (JRE) only, which does not contain javac. For javac, you have to install the OpenJDK Development Environment. You can install java-devel or java-1.6.0-openjdk-devel, which both include javac.

By the way: you can find out which package provides javac with a yum search, e.g.

su -c 'yum provides javac'

on more recent releases of CentOS e.g. 6 the command changes to

su -c 'yum provides */javac'

Another note: using yum and openjdk is only one possibility to install the JDK. Many people prefer Sun/Oracle's "original" SDK. See How to install Java SDK on CentOS? and links for alternatives.

查看更多
看我几分像从前
6楼-- · 2019-01-30 02:28

Make sure you install JDK/JRE first.

follow these steps:

open terminal go to your root dictionary by typing

cd /

you will see Library folder

Now follow this path Library/Java/JVM/bin

Once you get into bin you can see the javac file

Now you need to get the path of this folder for that just write this command

pwd

get the path for your javac.

查看更多
趁早两清
7楼-- · 2019-01-30 02:29

Is the javac executable in a directory that is part of your PATH?

I don't know the CentOS equivalent of the Windows path but if you cd to the java sdk directory and run ./javac does anything happen?

查看更多
登录 后发表回答