Java Tutorial
Java Basics
In this tutorial, we are going to learn about the basics of Java which is one of the most commonly used and simple programming languages. It is a high-level programming language that uses OOP(Object Oriented Programming) concept. In this Java tutorial, you will understand the features of Java and its various applications. We can use Java programming language in any desktop, web, or mobile applications.
In 1995, Sun Microsystems invented Java programming language and later Oracle Systems acquired it. In this Java tutorial, we will cover things in detail.
Java Programming Tutorial
You can jump directly to topics on Java programming tutorial from here → Java Tutorial
Java for Beginners
In this tutorial, we are targeting beginners to learn java programming language. Following are the basic java topics:
Java Environment
There are 3 main components in Java Environment as shown below.
JDK (Java Development Kit)
JDK is the complete Java development kit. It contains many components that include JRE, compilers, and various tools like JavaDoc, JavaDebugger, etc. We need JDK installed in our systems to compile and run any Java program.
JRE (Java Runtime Environment)
In order to execute any java program, we need JRE which is part of the JDK. Browser plugins, JVM and applets support are part of JRE.
JVM ( Java Virtual Machine)
JVM is part of JRE which is responsible to execute the bytecode that is generated by the compiler while compiling the java program. It produces the same output after executing bytecode in any operating system since every operating system has a different JVM. Hence Java is a platform-independent programming language which means we can execute a program in Linux though it is compiled on Windows or vice versa.
The below pictorial representation will help you understand how the Java program works which is the base of Java tutorial.
Java Features
Below are the main features of the Java programming language that you should know before understanding in depth about Java tutorial.
Platform Independent
Since the output which the JVM produces after executing the bytecode is the same in any operating system, we can compile the java program in 1 system and execute it another operating system. This is the reason for Java being known as platform-independent.
Object-Oriented
Java follows an object-oriented concept since we use a collection of objects of a class to perform any operation. It uses 4 main concepts of OOP like Abstraction, Polymorphism, Encapsulation, and Inheritance.
Simple
Java is a simple programming language since it does not use any complex programming concepts like pointers or multiple inheritances.
Secure
Java provides high security since it does not produce any security flaws like stack overflow, etc. This is because it does not mainly use the concept of pointers.
Robust
Java is the most reliable programming language since the java compiler identifies or detects errors in early-stage thus avoiding issues like garbage collection, memory allocation, exception handling, etc
Multithreaded
Java supports multithreading features which means we can execute 2 more programs concurrently and hence utilizing CPU to the maximum.
High Performace
Java has very high performance due to the usage of Just-in-time compilers.
Distributed
Java supports distributed programming which means we can distribute java programs in more than 1 system which is connected through the internet. We can use features like EJB(Enterprise Java Bean) and RMI(Remote Method Invocation) in Java to support distributed feature,
Dynamic
Java is more dynamic when we compare to other programming languages like C or C++. This is because it can carry a large amount of run time information which we can use to verify runtime object access.
Applications of Java
Java provides the platform to work for any type of application. For example, we use J2EE for building Enterprise Applications, J2ME for Mobile applications, etc. We can use Java for the below-mentioned applications
Stand-Alone Application
Web Application
Enterprise Application
Mobile Application
Stand-Alone Applications
This is nothing but a desktop application. Several desktop applications use Java as a programming language. We can install these applications in any machine to use. Mainly, we use AWT or Swing in Java to create stand-alone applications.
Web Applications
Web Application is an application that runs on the server-side. It includes any website that requires an internet connection. We can use Java technologies like Servlet, JSP, Struts, Hibernate, etc to build websites.
Enterprise Applications
Any application that is distributed in nature is an Enterprise Application like Banking application. The main technology which we use in Java for building Enterprise Application is EJB in J2EE.
Mobile Applications
Applications that run on mobile is a Mobile Application. We use J2ME technology in Java to build mobile apps for Android devices.
Java Platform/Editions
There are several editions or platforms available in Java as mentioned below:
Java SE – Java Standard Edition
As the name suggests, this is the standard Java version which includes basic APIs like java.lang, java.io, java.net, java.util, java.math, java.sql, etc. This edition also includes main core technologies like OOP, multithreading, AWT, Swing, Exception, String, etc.
Java EE – Java Enterprise Edition
We use this platform for creating web and enterprise applications. It supports technologies like EJB, Servlet, Web services, etc
Java ME – Java Micro Edition
This is a micro platform and we use this platform for building mobile applications. Java mainly supports building Android mobile applications.
Java FX
We can use Java FX to build internet applications that use lightweight APIs.
The latest version is Java 14 released in March 2020.
Sample Java Program
This is a simple Java program that prints the statement “Hello Java”. In the next Java tutorial, we will understand writing, compiling, and executing a Java program.
public class Sample{
public static void main(String[] args) {
System.out.println(“Hello Java”);
}
}
Conclusion
In this Java tutorial, we have learned about Java, its features, and various applications.
Reference
Java Tutorial for Beginners
Learn Java