Wednesday 30 August 2017

Configuration of Java and Javac in Ubuntu

Cited from apt-get install openjdk-7-jdk doesn't install javac. Why?

The proper Debian/Ubuntu way to configure which javac is pointed to by /usr/bin/javac is to use the update-alternatives command. You can do it interactively, and select from a list of available options:

sudo update-alternatives --config javac

Or you can specify which option you want on the command-line:
sudo update-alternatives --set javac /usr/lib/jvm/java-7-openjdk/bin/javac

Because of the way it stores the information, using update-alternatives is not exactly equivalent (but instead is considered preferable) to manually making /usr/bin/java a symbolic link to your javac of choice. See man update-alternatives for more information about this.

No comments:

Post a Comment