The Wayback Machine - https://web.archive.org/web/20240905225651/https://www.geeksforgeeks.org/introduction-to-java/
Open In App

Introduction to Java

Last Updated : 23 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Java is a class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is intended to let application developers write once, and run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation. Java was first released in 1995 and is widely used for developing applications for desktop, web, and mobile devices. Java is known for its simplicity, robustness, and security features, making it a popular choice for enterprise-level applications.

Java was developed by James Gosling at Sun Microsystems Inc in May 1995 and later acquired by Oracle Corporation. It is a simple programming language. Java makes writing, compiling, and debugging programming easy. It helps to create reusable code and modular programs. Java is a class-based, object-oriented programming language and is designed to have as few implementation dependencies as possible. A general-purpose programming language made for developers to write once run anywhere that is compiled Java code can run on all platforms that support Java. Java applications are compiled to byte code that can run on any Java Virtual Machine. The syntax of Java is similar to C/C++.

History of Java

Java’s history is as interesting as it is impactful. The journey of this powerful programming language began in 1991 when James Gosling, Mike Sheridan, and Patrick Naughton, a team of engineers at Sun Microsystems known as the “Green Team,” set out to create a new language initially called “Oak.” Oak was later renamed Java, inspired by Java coffee, and was first publicly released in 1996 as Java 1.0. This initial version provided a no-cost runtime environment across popular platforms, making it accessible to a broad audience. Arthur Van Hoff rewrote the Java 1.0 compiler to strictly comply with its specifications, ensuring its reliability and cross-platform capabilities.

  • Java evolved over time, with Java 2 introducing multiple configurations tailored for different platforms, showcasing its versatility.
  • In 1997, Sun Microsystems aimed to formalize Java through the ISO standards body but eventually withdrew from the process.
  • Despite not formalizing through ISO, Sun Microsystems offered most Java implementations at no cost, earning revenue by licensing specialized products such as the Java Enterprise System.
  • A significant milestone in Java’s history occurred on November 13, 2006, when Sun Microsystems released a large portion of the Java Virtual Machine (JVM) as free, open-source software.
  • By May 8, 2007, the core JVM code was fully available under open-source distribution terms.
  • Java was designed with core principles: simplicity, robustness, security, high performance, portability, multi-threading, and dynamic interpretation. These principles have made Java a preferred language for various applications, including mobile devices, internet programming, gaming, and e-business.
  • Today, Java continues to be a cornerstone of modern software development, widely used across industries and platforms.

If you want to know more, Check Out: The Complete History of Java Programming Language

Key Features of Java

1. Platform Independent

Compiler converts source code to byte code and then the JVM executes the bytecode generated by the compiler. This byte code can run on any platform be it Windows, Linux, or macOS which means if we compile a program on Windows, then we can run it on Linux and vice versa. Each operating system has a different JVM, but the output produced by all the OS is the same after the execution of the byte code. That is why we call java a platform-independent language.

2. Object-Oriented Programming

Java is an object-oriented language, promoting the use of objects and classes. Organizing the program in the terms of a collection of objects is a way of object-oriented programming, each of which represents an instance of the class.

The four main concepts of Object-Oriented programming are:

3. Simplicity

Java’s syntax is simple and easy to learn, especially for those familiar with C or C++. It eliminates complex features like pointers and multiple inheritances, making it easier to write, debug, and maintain code.

4. Robustness

Java language is robust which means reliable. It is developed in such a way that it puts a lot of effort into checking errors as early as possible, that is why the java compiler is able to detect even those errors that are not easy to detect by another programming language. The main features of java that make it robust are garbage collection, exception handling, and memory allocation.

5. Security

In java, we don’t have pointers, so we cannot access out-of-bound arrays i.e it shows ArrayIndexOutOfBound Exception if we try to do so. That’s why several security flaws like stack corruption or buffer overflow are impossible to exploit in Java. Also, java programs run in an environment that is independent of the os(operating system) environment which makes java programs more secure.

6. Distributed

We can create distributed applications using the java programming language. Remote Method Invocation and Enterprise Java Beans are used for creating distributed applications in java. The java programs can be easily distributed on one or more systems that are connected to each other through an internet connection.

7. Multithreading 

Java supports multithreading, enabling the concurrent execution of multiple parts of a program. This feature is particularly useful for applications that require high performance, such as games and real-time simulations.

8. Portability  

As we know, java code written on one machine can be run on another machine. The platform-independent feature of java in which its platform-independent bytecode can be taken to any platform for execution makes java portable. WORA(Write Once Run Anywhere) makes java application to generates a ‘.class’ file that corresponds to our applications(program) but contains code in binary format. It provides ease t architecture-neutral ease as bytecode is not dependent on any machine architecture. It is the primary reason java is used in the enterprising IT industry globally worldwide.

9. High Performance

Java architecture is defined in such a way that it reduces overhead during the runtime and at some times java uses Just In Time (JIT) compiler where the compiler compiles code on-demand basis where it only compiles those methods that are called making applications to execute faster.

If you want to master Java, check out the Java Programming – Basic to Advanced course by us. It’s perfect for taking your Java skills from beginner to expert.

How Java Code Executes

The execution of a Java application code involves three main steps:

How-Java-Code-Executes

How Java Code Executes

1. Creating the Program

Java programs are written using a text editor or an Integrated Development Environment (IDE) like IntelliJ IDEA, Eclipse, or NetBeans. The source code is saved with a .java extension.

2. Compiling the Program

The Java compiler (javac) converts the source code into bytecode, which is stored in a .class file. This bytecode is platform-independent and can be executed on any machine with a JVM.

3. Running the Program

The JVM executes the compiled bytecode, translating it into machine code specific to the operating system and hardware.

Example Program:

Java
public class HelloWorld {
    public static void main(String[] args)
    {
        System.out.println("Hello, World!");
    }
}

Write your first Java program with ‘First Java Program: Hello World‘.

Essential Java Terminologies You Need to Know

Before learning Java, one must be familiar with these common terms of Java.

1. Java Virtual Machine(JVM)

The JVM is an integral part of the Java platform, responsible for executing Java bytecode. It ensures that the output of Java programs is consistent across different platforms.

  • Writing a program is done by a java programmer like you and me.
  • The compilation is done by the JAVAC compiler which is a primary Java compiler included in the Java development kit (JDK). It takes the Java program as input and generates bytecode as output.
  • In the Running phase of a program, JVM executes the bytecode generated by the compiler.

Now, we understood that the function of Java Virtual Machine is to execute the bytecode produced by the compiler. Every Operating System has a different JVM but the output they produce after the execution of bytecode is the same across all the operating systems. This is why Java is known as a platform-independent language.

2. Bytecode

Bytecode is the intermediate representation of Java code, generated by the Java compiler. It is platform-independent and can be executed by the JVM.

3. Java Development Kit(JDK)

While we were using the term JDK when we learn about bytecode and JVM. So, as the name suggests, it is a complete Java development kit that includes everything including compiler, Java Runtime Environment (JRE), java debuggers, java docs, etc. For the program to execute in java, we need to install JDK on our computer in order to create, compile and run the java program.

4. Java Runtime Environment (JRE)

JDK includes JRE. JRE installation on our computers allows the java program to run, however, we cannot compile it. JRE includes a browser, JVM, applet support, and plugins. For running the java program, a computer needs JRE.

5. Garbage Collector

In Java, programmers can’t delete the objects. To delete or recollect that memory JVM has a program called Garbage Collector. Garbage Collectors can recollect the objects that are not referenced. So Java makes the life of a programmer easy by handling memory management. However, programmers should be careful about their code whether they are using objects that have been used for a long time. Because Garbage cannot recover the memory of objects being referenced.

6. ClassPath

The Classpath is the file path where the java runtime and Java compiler look for .class files to load. By default, JDK provides many libraries. If you want to include external libraries they should be added to the classpath.

Basically everything in java is represented in Class as an object including the main function.

Advantages of Java

  • Platform independent: Java code can run on any platform that has a Java Virtual Machine (JVM) installed, which means that applications can be written once and run on any device.
  • Object-Oriented: Java is an object-oriented programming language, which means that it follows the principles of encapsulation, inheritance, and polymorphism.
  • Security: Java has built-in security features that make it a secure platform for developing applications, such as automatic memory management and type checking.
  • Large community: Java has a large and active community of developers, which means that there is a lot of support available for learning and using the language.
  • Enterprise-level applications: Java is widely used for developing enterprise-level applications, such as web applications, e-commerce systems, and database systems.

Disadvantages of Java

  1. Performance: Java can be slower compared to other programming languages, such as C++, due to its use of a virtual machine and automatic memory management.
  2. Memory management: Java’s automatic memory management can lead to slower performance and increased memory usage, which can be a drawback for some applications.

Useful Resources:

Conclusion

Java is a powerful and versatile programming language that’s great for beginners and experienced developers alike. By learning the basics, like what classes, objects, and methods are, you can start creating your own programs and see how Java can be used in real-world applications. Whether you’re interested in building games, mobile apps, or websites, Java provides a solid foundation to bring your ideas to life. Remember, the more you practice, the better you’ll get. Keep exploring, and soon you’ll be writing your own Java programs with confidence!



Previous Article
Next Article

Similar Reads

Difference Between java.sql.Time, java.sql.Timestamp and java.sql.Date in Java
Across the software projects, we are using java.sql.Time, java.sql.Timestamp and java.sql.Date in many instances. Whenever the java application interacts with the database, we should use these instead of java.util.Date. The reason is JDBC i.e. java database connectivity uses these to identify SQL Date and Timestamp. Here let us see the differences
7 min read
Java | MIDI Introduction
Introduction: Java MIDI is a set of Java APIs for handling musical data and MIDI (Musical Instrument Digital Interface) devices. These APIs allow Java programs to access and manipulate MIDI data, and can be used to create applications such as music players, synthesizers, and more. The Java Sound API, which includes the MIDI package, provides a low-
8 min read
Introduction to Processing | Java
Processing is an open-source programming language and development environment that is built on top of the Java programming language. It is specifically designed for artists, designers, and other creative professionals who want to create interactive graphics, animations, and other visual applications. Processing was created in 2001 by Ben Fry and Ca
6 min read
Introduction to Java NIO with Examples
Java IO(Input/Output) is used to perform read and write operations. The java.io package contains all the classes required for input and output operation. Whereas, Java NIO (New IO) was introduced from JDK 4 to implement high-speed IO operations. It is an alternative to the standard IO API’s. In this article, we will understand more about Java NIO.
5 min read
Introduction to Checkstyle Plugin for Checking Java Code Quality
Checkstyle is a development tool to help programmers to write Java code that sticks to a coding standard. It automates the process of checking Java code. It is an open-source tool that checks code against a configurable set of rules. It allows you to define your own set of rules and check your code against it. These rules can be used in your IDE or
5 min read
Introduction to Java Servlets
Today, we all are aware of the need to create dynamic web pages i.e. the ones that can change the site contents according to the time or can generate the content according to the request received from the client. If you like coding in Java, then you will be happy to know that using Java there also exists a way to generate dynamic web pages and that
7 min read
Introduction to Key Encapsulation Mechanism API in Java
Key Encapsulation Mechanism (KEM) is nothing but it is a cryptographic technique used to securely encapsulate the symmetric cryptographic keys within the asymmetric key pairs. In Java, Java Cryptography Architecture (JCA) provides the APIs for implementing the various cryptographic operations which are including the Key Encapsulation Mechanism. Jav
4 min read
Introduction to Java Mission Control for JVM Monitoring
Java Mission Control (JMC) is a powerful monitoring, diagnostics, and performance analysis tool. Oracle provides this to run the Java applications on the Java Virtual Machine. It is part of the Java Development Kit and offers developers and administrators insights into the runtime behaviour of Java applications. The JMC is useful for identifying pe
5 min read
Introduction to JDBC (Java Database Connectivity)
JDBC stands for Java Database Connectivity. JDBC is a Java API to connect and execute the query with the database. It is a specification from Sun Microsystems that provides a standard abstraction(API or Protocol) for Java applications to communicate with various databases. It provides the language with Java database connectivity standards. It is us
6 min read
Introduction to Java Swing
Swing is a Java Foundation Classes [JFC] library and an extension of the Abstract Window Toolkit [AWT]. Java Swing offers much-improved functionality over AWT, new components, expanded components features, and excellent event handling with drag-and-drop support. Introduction of Java SwingSwing has about four times the number of User Interface [UI]
8 min read
Java AWT vs Java Swing vs Java FX
Java's UI frameworks include Java AWT, Java Swing, and JavaFX. This plays a very important role in creating the user experience of Java applications. These frameworks provide a range of tools and components for creating graphical user interfaces (GUIs) that are not only functional but also visually appealing. As a Java developer, selecting the righ
11 min read
Introduction to Hibernate Framework
Prerequisite : JDBC Need of Hibernate Framework Hibernate is used to overcome the limitations of JDBC like: JDBC code is dependent upon the Database software being used i.e. our persistence logic is dependent, because of using JDBC. Here we are inserting a record into Employee table but our query is Database software-dependent i.e. Here we are usin
4 min read
JavaTuples | Introduction
Tuple The word "tuple" means "a data structure consisting of multiple parts". Hence Tuples can be defined as a data structure that can hold multiple values and these values may/may not be related to each other. Example: [Geeks, 123, &#*@] In this example, the values in the tuple are not at all related to each other. "Geeks" is a word that has a mea
6 min read
Introduction to the Spring Data Framework
In the previous article, we have already discussed about spring framework and spring boot. In this article, we will understand about spring data framework. The need for Spring Data Framework Our digital world is holding more than 20 zettabytes of data, and that is around as many bits of information as the stars in our physical universe. These data
5 min read
Introduction of BlueJ
BlueJ is a windows based platform for Java Development Kit (JDK). It is a free Java environment started in 1999 by Michael Kolling and John Rosenberg at Monash University, Australia, as a successor to Blue. It requires to install JDK version 1.3 or more before installing BlueJ. It can be freely downloaded from its official website of BlueJ. It was
3 min read
Introduction to Gradle
Gradle is an excellent open-source construction tool that is capable of the development of any kind of software. This tool was developed by a gaggle of developers named Hans Dockter, Szczepan Faber Adam Murdoch, Luke Daley, Peter Niederwieser, Daz DeBoer, and Rene Gröschkebefore 13 years before. It is an automation tool that is based on Apache Ant
8 min read
Introduction to Activities in Android
Activity class is one of the very important parts of the Android Component. Any app, don't matter how small it is (in terms of code and scalability), has at least one Activity class. Unlike most programming languages, in which the main() method is the entry point for that program or application to start its execution, the android operating system i
6 min read
Introduction to Spring Framework
Prior to the advent of Enterprise Java Beans (EJB), Java developers needed to use JavaBeans to create Web applications. Although JavaBeans helped in the development of user interface (UI) components, they were not able to provide services, such as transaction management and security, which were required for developing robust and secure enterprise a
10 min read
Spring Boot - Introduction to RESTful Web Services
RESTful Web Services REST stands for REpresentational State Transfer. It was developed by Roy Thomas Fielding, one of the principal authors of the web protocol HTTP. Consequently, REST was an architectural approach designed to make the optimum use of HTTP protocol. It uses the concepts and verbs already present in HTTP to develop web services. This
5 min read
Introduction to Using FreeMarker in Spring MVC
FreeMarker is the Apache Software Foundation that produces the Java-based template engine. The MVC paradigm is supported by FreeMarker, just like it is by other template engines, for HTML web pages in apps. To utilize FreeMarker instead of JSP with Spring MVC, follow this guide to configure it. Four popular template engines are supported by Spring
3 min read
Introduction to Apache POI
Apache POI is an open-source java library to create and manipulate various file formats based on Microsoft Office. Using POI, one should be able to perform create, modify and display/read operations on the following file formats. For Example, Java doesn’t provide built-in support for working with excel files, so we need to look for open-source APIs
3 min read
Introduction to Spring Cloud Stream
Spring framework always aspired to simplify enterprise Java development. They offered Spring Boot framework to simplify creating Java-based microservices. Similarly, the Spring Integration framework was designed to provide a solution for simplified application integration. However, some modern enterprise applications started to implement distribute
7 min read
Introduction and Working of Struts Web Framework
Struts is an open-source web application framework developed by Apache Software Foundation, it is used to create a web application based on servlet and JSP. It depends on the MVC (Model View Controller) framework. Struts are thoroughly useful in building J2EE (Java 2 Platform, Enterprise Edition) applications because struts take advantage of J2EE d
3 min read
Introduction to Spring Boot
Spring is widely used for creating scalable applications. For web applications Spring provides Spring MVC which is a widely used module of spring which is used to create scalable web applications. But main disadvantage of spring projects is that configuration is really time-consuming and can be a bit overwhelming for the new developers. Making the
5 min read
Introduction to Spring Security and its Features
Spring Security is one of the projects by the Spring team that is built using the Spring framework in Java. This project aims to make it easy for developers to secure web applications against common exploits such as Cross-Site Request Forgery (CSRF) attacks. It contains code that can be customized or used as-is, depending on the use case. Its major
4 min read
JPA - Introduction
JPA can be defined as Java Persistence API. It is the Java specification that can provide a standardized way to manage the relational data in Java applications. JPA facilitates the management of the database operations and mapping of the Java objects to database tables by defining the concepts and APIs. It serves as the bridge between the object-or
4 min read
Introduction to WireMock
WireMock is a tool for mocking HTTP-based APIs that run in the unit tests, on the desktop, or in the test environment. We can also say it is a simulator for HTTP-based APIs, considered a service virtualization tool or a mock server. It enables you to stay productive when an API you depend on Doesn't exist orIsn't complete orCostly to accessIt suppo
6 min read
Apache JMeter - An Introduction
Apache JMeter is a pure Java-based open-source software application used for testing load testing functional behavior and measuring performance. It is used for testing a variety of services,i.e. web applications, databases, etc. Apache JMeter FeaturesFeatures of JMeter that make it so powerful are mentioned below: Performance Testing:Performance is
3 min read
Java.io.ObjectInputStream Class in Java | Set 2
Java.io.ObjectInputStream Class in Java | Set 1 Note : Java codes mentioned in this article won't run on Online IDE as the file used in the code doesn't exists online. So, to verify the working of the codes, you can copy them to your System and can run it over there. More Methods of ObjectInputStream Class : defaultReadObject() : java.io.ObjectInpu
6 min read
Java.lang.Class class in Java | Set 1
Java provides a class with name Class in java.lang package. Instances of the class Class represent classes and interfaces in a running Java application. The primitive Java types (boolean, byte, char, short, int, long, float, and double), and the keyword void are also represented as Class objects. It has no public constructor. Class objects are cons
15+ min read
Article Tags :
Practice Tags :