Programming Languages Section

Java

Card image
Post by Amina Delali, July 01st,2020

Some Facts

Java is an object oriented programming. It can be used to implement different type of software: from desktop to web applications. Its main feature is its JVM (Java Virtual Machine)

that allows the code to be run in an environment independent from the platform from which the code is run.

The official implementation of Java is owned by Oracle Corporation.

To run a Java program, you must have installed the Java Runtime Environement, and to develop code you have to install the Java Development Kit.

You can use a free or a paid distribution of the JDK. The open source version ( OpenJDK ) is free to use. But there is a commercial version that you can acquire via licensing.




How to install it on Ubuntu

In order to install Java and start programming, you have only to use the Ubuntu package manager:

sudo apt update
sudo apt install default-jdk

Then you have to set JAVA_HOME variable. To do this, first you have to identify Java path:

sudo update-alternatives --config java

After that , you use part of the path to set the JAVA_HOME variable by editing the /etc/environment file.

/etc/environment

It may for example look like this:

JAVA_HOME = “lib/jvm/java-11-oopenjdk-amd64”

Then, in order to let the new variable available and be used, you can type this:

source /etc/environment


All the details are explained in the video available here .

The Hello World Example

Int the below video corresponding to the code, I will explain how to show the message Hello World :

1- Showed on a console

1 -Showed in a popup window ( using JoptionPane class )

When you write your code, it will be saved in a file with the “.java” extension. Then you generate the corresponding class file with the javac command. To run it, use the java command.

Something to say ?

If you want to add something about the Java language or about this post, please feel free to do it by commenting below 🙂 .