Installing Java JDK in Ubuntu Terminal
- Go to terminal mode in Ubuntu and enter:
- javac -version
- if this command gives you the following or similar message:
-
- The program 'javac' can be found in the following packages:
- * default-jdk
- * ecj
- * gcj-5-jdk
- * openjdk-8-jdk-headless
- * gcj-4.8-jdk
- * gcj-4.9-jdk
- * openjdk-9-jdk-headless
- Try: sudo apt install
-
- it means that the JDK is NOT installed, and you need to run the following command:
-
- sudo apt install openjdk-9-jdk-headless
- then enter again: javac -version
- and you should get: javac 9-internal
-
- If you get the same above error, run again
- sudo apt install openjdk-9-jdk-headless
- Very rarely you need to install the JDK twice following the above instructions.