LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-26-2010, 10:27 AM   #1
KuraShoko
LQ Newbie
 
Registered: Jul 2010
Posts: 2

Rep: Reputation: 0
Question :bash java: command not found


Hi everyone, I've just installed java (jre-6u21-linux-i586.bin) on Red Hat 4.4 AS and issued this command to check the java version: java -version
and got :bash :java: command not found
 
Old 07-26-2010, 10:34 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,550

Rep: Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898Reputation: 2898
So this tells you that the java executable is not in your current path.

Have a look at your install instructions and see if maybe an environment variable needs to be set (maybe JAVA_HOME)

Also, do a find and make sure that the executable does actually exist somewhere??
 
Old 07-26-2010, 10:56 AM   #3
alli_yas
Member
 
Registered: Apr 2010
Location: Johannesburg
Distribution: Fedora 14, RHEL 5.5, CentOS 5.5, Ubuntu 10.04
Posts: 559

Rep: Reputation: 92
If you try:

Code:
#which java
It should confirm post #2 in that your JAVA_HOME environment variable does not exist AND that you haven't added the executable directory of your Java installation into your PATH.

Basically you need to add the following to your bash_profile:

Code:
export JAVA_HOME=/path/to/my/java/installation/
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
Once in your PATH at an OS level you can run java -version.

Having JAVA_HOME setup is also very useful in that your application servers and/or IDE will look for this variable.
 
Old 07-26-2010, 11:25 AM   #4
KuraShoko
LQ Newbie
 
Registered: Jul 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you. Will try your suggestions and post feedback
 
Old 07-26-2010, 12:03 PM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2017 CentOS6.9 CentOS7.3 + 50+ other Linux OS, for test only.
Posts: 16,735

Rep: Reputation: 3317Reputation: 3317Reputation: 3317Reputation: 3317Reputation: 3317Reputation: 3317Reputation: 3317Reputation: 3317Reputation: 3317Reputation: 3317Reputation: 3317
The CentOS way : Something like this :
1) su
2)
Code:
/usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_21/bin/java 2
( /usr/sbin/alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_21/bin/javac 2  )
3) /usr/sbin/alternatives --config java
(( 4) /usr/sbin/alternatives --config javac ))
..

Last edited by knudfl; 08-01-2010 at 09:05 AM.
 
  


Reply

Tags
alternatives, jdk6


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
java -version, bash: java: command not found kirman Programming 4 03-20-2008 12:13 AM
-bash: java: command not found vinbase Linux - Newbie 1 01-01-2008 06:52 PM
(Debian) bash: java: command not found pjpeter Linux - Newbie 3 09-25-2004 03:59 PM
bash: java: command not found pjpeter Programming 4 09-24-2004 04:02 PM
java command - "bash: java: command not found" ??? RedHat123 Programming 2 07-17-2002 12:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration