How to Setup Vs Code For Java in Ubuntu 20.04.3 (Linux)
#vscode #ubuntu #Java
Java is a High-level and Object-Oriented Programming Language in the Coding World. Mainly, People use Java for Crafting Desktop GUI applications, Mobile Apps, Back-end Apps, Gaming Applications, and IoT Applications.
Setting Up Java in the Linux World is very straightforward but more confusing for those who just started Using Linux. In this blog, We are going to install Java SDK and Vs code in your respective Ubuntu.
Install Vs Code
You can use the following command to do so
$ sudo snap install --classic code
Install snap if you get an error for installing Snap, use below command
$ sudo apt update
$sudo apt install snapd
Install Extension for Java in Vs Code
Install the following Extensions given below:
Extension Name - Extension Pack for Java
Extension Name - Code Runner
Find and install the Latest Version of Java JDK
METHOD 1: Install via Command line
The latest version of Java JDK is 17. let's install this version using Command-Line which is given below
$ sudo apt install openjdk-17-jdk-headless
You will get a similar code while installing
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
ca-certificates-java java-common openjdk-17-jre-headless
Suggested packages:
default-jre openjdk-17-demo openjdk-17-source fonts-dejavu-extra
fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei
| fonts-wqy-zenhei
The following NEW packages will be installed:
ca-certificates-java java-common openjdk-17-jdk-headless
openjdk-17-jre-headless
0 upgraded, 4 newly installed, 0 to remove and 1 not upgraded.
Need to get 286 MB of archives.
After this operation, 445 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu focal/main amd64 java-common all 0.72 [6,816 B]
Get:2 http://in.archive.ubuntu.com/ubuntu focal-updates/universe amd64 openjdk-17-jre-headless amd64 17.0.1+12-1~20.04 [43.5 MB]
Get:3 http://in.archive.ubuntu.com/ubuntu focal/main amd64 ca-certificates-java all 20190405ubuntu1 [12.2 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu focal-updates/universe amd64 openjdk-17-jdk-headless amd64 17.0.1+12-1~20.04 [242 MB]
Fetched 286 MB in 1min 26s (3,337 kB/s)
Selecting previously unselected package java-common.
(Reading database ... 388308 files and directories currently installed.)
Preparing to unpack .../java-common_0.72_all.deb ...
Unpacking java-common (0.72) ...
Selecting previously unselected package openjdk-17-jre-headless:amd64.
Preparing to unpack .../openjdk-17-jre-headless_17.0.1+12-1~20.04_amd64.deb ...
Unpacking openjdk-17-jre-headless:amd64 (17.0.1+12-1~20.04) ...
Selecting previously unselected package ca-certificates-java.
Preparing to unpack .../ca-certificates-java_20190405ubuntu1_all.deb ...
Unpacking ca-certificates-java (20190405ubuntu1) ...
METHOD 2: Install via Browser
Visit the Official Oracle Java JDK website or Click on the link given below
Download and install Java JDK for your respective operating system and Distros.
Let's Write and Run our first Program in Java.
Create First Java file in Vs code-named main.java
Click on the run button which is given on the top right corner and run your program. After Running the program, it should look like this.
Comments