In this tutorial, we will install java and try our first program :
- Verify that you have not already installed Java
- Install Ubuntu’s default JDK
- Test Java on the command line
- Set JAVA_HOME globally for all Ubuntu users
- Write your first program
- Compile the program
- Run the program
$java -version
$sudo apt-get update
$sudo apt install default-jdk
$java -version
$update-alternatives --config java
$sudo nano /etc/environment
$JAVA_HOME="/lib/jvm/java-11-openjdk-amd64/bin/java"
ctrl+o
enter
ctrl+x
$source /etc/environment
$echo $JAVA_HOME
$ gedit Hello_World.java
![image](https://github.com/ykarray/install_java/blob/main/java.png)
$javac Hello_World.java
$java Hello_World