What is Java Programming?
Java programming language is an OOP that is used to represent anything in the form of an object. The concept of Object makes a significant change in the programming industry which let developers to represent real problems in a set of Objects Where the object is represented with a set of object properties and behaviors.
The simplicity of the object oriented makes the programming practice easier to add new things, inherit existing behaviors and properties, increase flexibility, efficiency as well in code maintenance.
Java programming language is most popular programming language, and it has been used for desktop, mobile, and data processing and embedded system. For this reason, more than 3 billion devices according to Oracle who own Java reported that devices worldwide are using Java programming language.
There are a lot of features to discuss in Java programming in the coming Chapter starting from a simple concept to a more advanced, and complex real problem resolving.
Precondition
To build Java programs, you need to have Java Development Kit (JDK) installed on your device. To install on their local machine download the Oracle Oracle website and install the JDK.
Configure Environment Variables
Environment variable is a must to configure. The main purpose of setting environment variable is to let the Java accessible and execute any Java related compilation or usage of Java command.
The configuration starts by accessing or creating a file ~/.bash_profile. To open or create the file use the command nano ~/.bash_profile. Then add in the file the JAVA_HOME and PATH. Finally Press Ctrl + X to exit, then Press Y to save the changes, and Enter to confirm the filename.
STEP-1
nano ~/.bash_profile
STEP-2
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH
After the configuration of the environment variable, it is possible to check the Java version using the command java –version.
Writing Your First Java Program
In order to write the first Java program, create a file and write down the following Java program inside the file, and save the file with the file extension .Java. The file name should have the same name of the className. And the class name should include the main method where the execution suppose to begin. Detail of Java Program will be discussed in the next topics. of our discussion.
class HelloWorld{
public static void main (String [] ags){
System.out.println("Hello");
}
}
The next step to compile the file where the file is created and stored.
java HelloWorld.java
After successful compilation, execution of the program will be the next action. In order to run the program, apply the following command
java HelloWorld