First off, I'm on a VPS running CentOS 6. I already downloaded the RPM, set the alternatives --config java. But when I do: java -verison, it says command not found. But when I install OpenJDK, It works fine. I create my own plugins(Even though I'm new here) but they require Java version 1.7.
Yeah you should use bash or shell script as it's written to add java to your path. And then the command will be available
Now the alternative command does not work. Here is my .bashrc file: Code: # .bashrc # User specific aliases and functions alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi PATH ="$PATH":/usr/java/jre1.7.0_05/bin export PATH
What are all these lines ? You just need : PATH="$PATH":/usr/local/jdk1.6.0/bin or set path="$PATH":/usr/local/jdk1.6.0/bin
This is what I do to install Java. I install the JDK, not the JRE. The JDK includes the JRE, but it includes other things such as a compiler. My distro is fedora, which is based on red hat (cent is also based on red hat). I use update-alternatives and it works fine, no need to mess with bashrc. Download java somehow... Oracle's download links are non-wget friendly and they are like ass, but the file you want is "jdk-7u5-linux-x64.tar.gz" or "jdk-7u5-linux-i586.tar.gz" if you are on a 32-bit system. Extract the tarball that contains the JDK. Code: tar -xvf jdk-7u5-linux-YOURARCH.tar.gz (replace YOURARCH with the architecture of the file you downloaded, i586 or x64) Run this to move your JDK folder to an appropriate location. Code: sudo mv ./jdk1.7.0_05 /usr/lib/jvm/jdk1.7.0 Now use update-alternatives to register java, javac, and javaws. Code: sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1 sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1 sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1 Configure update-alternatives and choose the correct path! Code: sudo update-alternatives --config java For --config java, the correct path would be "/usr/lib/jvm/jdk1.7.0/jre/bin/java", for example.Afterwards, you have to configure the other two executables. Code: sudo update-alternatives --config javac sudo update-alternatives --config javaws After you complete the installation, make sure you test your setup and make sure you are using the correct version of Java. Code: java --version