In Oracle Enterprise Linux when I type java
I am getting
bash: java: command not found
I have installed Java 1.6 and I have the following
sudo update-alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
* 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
+ 2 /usr/java/jre1.6.0_24/bin/java
How can I resolve this issue?
Thanks
Here are the three easiest ways to fix Java's “not recognized as an internal or external command” error: Install or reinstall Java and the JDK on your computer. Add Java's bin directory to the computer's PATH. Restart the command prompt, terminal window or PowerShell.
Alternatively, you can use the whereis command and follow the symbolic links to find the Java path. The output tells you that Java is located in /usr/bin/java. Inspecting the directory shows that /usr/bin/java is only a symbolic link for /etc/alternatives/java.
To check which version of Java is installed, follow this procedure: -Open a Linux command prompt. -Enter the command java -version. -If Java version is installed on your system, you see a Java installed response.
You can add one of the Java path to PATH variable using the following command.
export PATH=$PATH:/usr/java/jre1.6.0_24/bin/
You can add this line to .bashrc file in your home directory. Adding this to .bashrc will ensure everytime you open bash it will be PATH variable is updated.
I had these choices:
-----------------------------------------------
* 1 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
+ 2 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
3 /home/ec2-user/local/java/jre1.7.0_25/bin/java
When I chose 3, it didn't work. When I chose 2, it did work.
I found the best way for me was to download unzip then symlink your new usr/java/jre-version/bin/java
to your main bin as java.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With