Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 02-05-2014, 11:19 AM   #1
LQ Newbie
Registered: Mar 2013
Posts: 12

Rep: Reputation: Disabled
java installation

I tried to install java and was successful in downloading the rpm and installing jdk1.7.0_51 but the problem is I installed it to a created directory called java under the root. So now when I type java -version I get bash: java: command not found. I found some posts that advise adding the following:
export JAVA_HOME=mydirectory( which in this case is java)
Can someone advise what to do here and also if I download programs do I let it install in the default directory as root or is there an equivalent ProgramFiles folder?
Old 02-05-2014, 02:09 PM   #2
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,913
Blog Entries: 14

Rep: Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142Reputation: 1142
command not found
Means it didn't find the command. That means either it doesn't exist, it isn't accessible or it doesn't know where to look.

The most likely culprit being it doesn't know where to look.

You can fix that simply either:
1) Adding the directory where the java command is to your PATH variable.
2) Creating a symbolic link from where the java command is to a directory that is already in your PATH variable.
3) Typing the full path to where the binary is.

To see your PATH variable type "echo $PATH". You should see something like:
Each of the items separated by the colons is a directory that will be searched when you type a command without a full path.

So if you the above PATH but the new install put your java binary in say /usr/lib/java1.7/bin/java you could either append the directory to your PATH:
export PATH=$PATH:/usr/lib/java1.7/bin
Create the link:
ln -s /usr/lib/java1.7/bin/java /usr/local/bin/java

Also the above export would add it to your running PATH but would not add it for new sessions. To do that you'd have to modify the PATH= statement in the specific user's home directory file (e.g. .bashrc or .bash_profile) or if you want it for all users to the global profile such as /etc/profile or /etc/bashrc. (Note that after adding to a file a user has to either log out and login again or source the modified file for the change to take effect.)
Old 02-05-2014, 02:20 PM   #3
John VV
LQ Muse
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,115

Rep: Reputation: 2480Reputation: 2480Reputation: 2480Reputation: 2480Reputation: 2480Reputation: 2480Reputation: 2480Reputation: 2480Reputation: 2480Reputation: 2480Reputation: 2480
What OS are you using , fedora,cent/RHEL already have OpenJDK already installed BY DEFAULT

every rpm based system already has Openjdk installed!!!
If you want to replace that DEFAULT program with Oracles JAVA
you need to RESET "Alternatives"

but the problem is I installed it to a created directory called java under the root.
DO NOT !!!!!!!!!! try to install java to a folder in the root home folder !!!!!!

do NOT run it as root !!!!!!!

for a rpm you use "yum" for Fedora/RHEL and "zypper" for opensuse
and use your package manager !!!( yum on centos)

for fedora
PLEASE READ and FALLOW the Mjmwired guide!
-- slightly old but still good

if you are using the current CentOS 6.5
openjdk is installed BY DEFAULT ( icetea)

Last edited by John VV; 02-05-2014 at 02:21 PM.


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 installation rob.rice Slackware 5 11-25-2012 02:22 PM
JAVA JRE installation to view java applet through browser dipenchaudhary Linux - Software 1 01-23-2006 09:20 AM
Java Installation kaplan71 Debian 2 12-30-2005 09:39 AM
java installation Prageem Linux - Software 4 09-20-2005 10:48 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:41 AM.

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