arVahedi
arVahedi

Reputation: 107

java : command not find


i have a problem with install jdk on my centos.
i did install "java-1.8.0-openjdk-1.8.0.25-3.b17.el6_6.i386" but yet when i run "java -version", i see this error:

[root@JAVA java]# java -version

-bash: java: command not found

i set $PATH variable too:

[root@JAVA java]# echo $PATH

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:/root/bin:/root/bin:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.25-3.b17.el6_6.i386/jre/bin:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.25-3.b17.el6_6.i386/jre/bin/

what is wrong? i really tried to search. :( plz help me.

update:
i locate for jre and this return:

[root@JAVA java]# locate jre
/etc/alternatives/jre
/etc/alternatives/jre_1.8.0
/etc/alternatives/jre_1.8.0_exports
/etc/alternatives/jre_1.8.0_openjdk
/etc/alternatives/jre_1.8.0_openjdk_exports
/etc/alternatives/jre_exports
/etc/alternatives/jre_openjdk
/etc/alternatives/jre_openjdk_exports
/usr/lib/jvm/jre
/usr/lib/jvm/jre-1.7.0
/usr/lib/jvm/jre-1.7.0-openjdk
/usr/lib/jvm/jre-1.8.0
/usr/lib/jvm/jre-1.8.0-openjdk
/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.25-3.b17.el6_6.i386
/usr/lib/jvm/jre-openjdk
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.25-3.b17.el6_6.i386/jre
/usr/lib/jvm-exports/jre
/usr/lib/jvm-exports/jre-1.7.0
/usr/lib/jvm-exports/jre-1.7.0-openjdk
/usr/lib/jvm-exports/jre-1.8.0
/usr/lib/jvm-exports/jre-1.8.0-openjdk-1.8.0.25-3.b17.el6_6.i386
/usr/lib/jvm-exports/jre-openjdk
/var/lib/alternatives/jre_1.7.0
/var/lib/alternatives/jre_1.8.0
/var/lib/alternatives/jre_1.8.0_openjdk
/var/lib/alternatives/jre_openjdk

which that is current path?

update 2:

[root@JAVA java]# yum list installed| grep java
java-1.7.0-openjdk.i686  1:1.7.0.65-2.5.1.2.el6_5
java-1.7.0-openjdk-devel.i686
java-1.8.0-openjdk.i686  1.8.0.25-3.b17.el6_6
java-1.8.0-openjdk-devel.i686
java-1.8.0-openjdk-headless.i686
tzdata-java.noarch       2014h-1.el6     @updates
[root@JAVA java]# find / -name "java"
/usr/share/bash-completion/java
/usr/share/java
/usr/lib/java
/usr/lib/jvm-exports/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.25-3.b17.el6_6.i386/bin/java
/usr/lib/jvm/java
/usr/bin/java
/var/lib/alternatives/java
/etc/alternatives/java
/etc/pki/java
/etc/java

Upvotes: 3

Views: 18143

Answers (3)

Yassine Boulam
Yassine Boulam

Reputation: 1

i had the same thinks , it was the encoder BOM UTF8 to UTF8

Upvotes: -1

sergpank
sergpank

Reputation: 988

if you are going to compile some java code you gonna need to use javac command which is located at JDK/bin/. All your system is targeted on JDK/jre/bin.

If there is no java configured create a symlink at /usr/bin

cd /usr/bin
ln -sfvn /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.25-3.b17.el6_6.i386/bin/java java

The better and cleaner approach is to create symlink java which will let you easily update java version in future:

cd /usr/lib/jvm/
ln -sfvn java-1.8.0-openjdk-1.8.0.25-3.b17.el6_6.i386 java
ln -sfvn java/jre jre

cd /usr/bin
ln -sfvn /usr/lb/jvm/java/bin/java java

Such approach will give you a cleaner and clearer environment.

You can also try alternatives command - Why is alternatives command used when installing Java on a Linux machine

But this is not really necessary.

Upvotes: 2

Altmish-E-Azam
Altmish-E-Azam

Reputation: 1583

Add below two lines in bashrc and profile files in /etc directory.

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.25-3.b17.el6_6.i386
export PATH=$JAVA_HOME/bin:$PATH

And try java -version. Still any problem please restart your OS once.

Upvotes: 6

Related Questions