Showing posts with label javac. Show all posts
Showing posts with label javac. Show all posts

Java not found or wrong java version - update-alternatives on Linux environment


Hola!

OK so let's rock... here are the possible problems:
0. No java / javac found.
1. Somehow you have two or more java (JRE or/and JDK) installed on the system.
2. Setting JAVA_HOME to your preferred version does not help as some stuff still use system default version
3. Cannot find javac or java even if JAVA_HOME set.


Strange but can happen if more than one version installed.

Time for some fixes:
Let say your preferred JAVA_HOME is pointing to /home/user/jdk

For setting JAVA_HOME and PATH please refer to the post:
Setting JAVA_HOME environment variable

System alternatives and updates

1. Install some java alternatives:
sudo update-alternatives --install /usr/bin/java java /home/user/jdk/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /home/user/jdk/bin/javac 1
sudo update-alternatives --install /usr/bin/javac javaws /home/user/jdk/bin/javaws 1

2. Set / notify the system:
sudo update-alternatives --set java /home/user/jdk/bin/java
sudo update-alternatives --set javac /home/user/jdk/bin/javac
sudo update-alternatives --set javaws /home/user/jdk/bin/javaws

3. Set the preferred one if have more alternatives
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws


This is it! You should be up an running with your old new great JAVA world :)