Installing Java on Ubuntu 12.04 can be done using the package manager "apt-get". Here is an example of the steps to install Java on an Ubuntu 12.04 system using apt-get:
- Update the package lists on your system by running the following command:
sudo apt-get update
- Install the OpenJDK package by running the following command:
sudo apt-get install openjdk-7-jdk
- Verify that Java is installed by running the following command:
java -version
- To set the default Java version, you can use the update-alternatives command:
sudo update-alternatives --config java
You will be prompted to choose the version of Java you want to use as the default. Select the appropriate option by entering the number next to it.
To set the JAVA_HOME environment variable, you can add the following line to your /etc/environment file:
JAVA_HOME="/usr/lib/jvm/java-7-openjdk-i386"
After adding the line, you must logout and login again for the changes to take effect.
Verify that the JAVA_HOME variable is set by running the following command:
echo $JAVA_HOME
This is a basic example of how to install and configure Java on an Ubuntu 12.04 system using apt-get. You can also customize and optimize the configuration according to your specific needs and requirements. This is example of OpenJDK, you can also install Oracle JDK by adding