1 of 13

Programming in Java

Module -1

An Introduction

Prepared by: Dr. Goutam Majumder

2 of 13

Index

  • About Java
  • The Creation of Java
  • The bytecode
  • Just-in-Time Compiler
  • The Java Buzzwords
  • Evaluation of Java

Prepared by: Dr. Goutam Majumder

3 of 13

What is Java?

  • Java is both a programming language and a software platform. Here's a breakdown of what that means:
  • Programming Language: Java is a widely used, general-purpose language for creating computer programs. It's known for being:
    • Object-oriented: Code is organized around objects, making it modular and reusable.
    • Platform-independent: "Write once, run anywhere" - Java code can run on any system with a Java Virtual Machine (JVM). This makes Java applications portable.
    • Relatively simple: Java has a clear syntax and structure, making it easier to learn than some other languages.

Prepared by: Dr. Goutam Majumder

4 of 13

What is Java?

Software Platform: Java provides a complete environment for developing and running applications. Here are some key components:

    • Java Development Kit (JDK): This includes tools for creating Java programs, including a compiler that turns your code into bytecode.
    • Java Runtime Environment (JRE): This allows computers to run Java programs. The bytecode instructions are interpreted by the JVM, which is part of the JRE.

Prepared by: Dr. Goutam Majumder

5 of 13

What is Java?

Java is used to develop a wide variety of applications, including:

    • Web applications: A large portion of web applications use Java for server-side development.
    • Mobile apps: Java is used to create apps for Android devices.
    • Desktop software: Many popular desktop applications are written in Java.
    • Big data processing: Java is a popular choice for working with large datasets.
    • And more: Java's versatility makes it applicable in many areas of computing.

Prepared by: Dr. Goutam Majumder

6 of 13

The Creation of Java

  • Java's creation story involves a team effort led by James Gosling at Sun Microsystems (now Oracle) in the early 1990s. Here are some key points:
  • Original Goal: The project initially aimed to develop a language for interactive television, but the technology wasn't quite ready for that purpose at the time.
  • Name Game: Java wasn't always called Java! It started as "Oak" but later transitioned to "Green" before finally landing on "Java," inspired by a type of coffee.
  • Design Principles: The core goals for Java were to make it:
    • Simple and familiar for programmers already using C/C++.
    • Robust and secure.
    • Portable across different computer systems (write once, run anywhere).
    • High-performing and efficient.

Prepared by: Dr. Goutam Majumder

Java 1.0 was first released in 1996. It quickly gained popularity due to its platform independence and object-oriented approach. Java continues to be a widely used language for various applications today.

7 of 13

How Java changed the Internet?

Java played a significant role in shaping the internet landscape in a couple of key ways:

  • Applets: One of Java's major innovations was the introduction of applets. Applets are small Java programs designed to be downloaded and run within a web browser. This offered a new level of interactivity compared to static web pages
  • Platform-Independent Development: Before Java, web development often involved creating different versions of content for various operating systems. Java's "write once, run anywhere" philosophy changed that. Developers could write Java code knowing it would run on any system with a Java Runtime Environment (JRE) installed. This made web development more efficient and standardized.

Prepared by: Dr. Goutam Majumder

While applets are less common today due to security concerns and the rise of alternative technologies, Java's impact on the internet goes beyond that. Its influence on server-side development and overall web application creation remains significant.

8 of 13

The magic Java Byte Code

  • It's a set of instructions specifically designed for the Java Virtual Machine (JVM). Imagine bytecode as a universal language that the JVM can interpret and execute, regardless of the underlying operating system. Each bytecode instruction is a single byte, making it compact.
  • When you compile a Java program, the source code is translated into bytecode stored in a .class file. This bytecode is not specific to any particular hardware and can be run on any machine with a JVM.
  • The JVM acts as an interpreter for bytecode. It reads the bytecode instructions in the .class file and translates them into machine code that the specific processor can understand and execute. In some cases, the JVM might also use Just-In-Time (JIT) compilation to further optimize the bytecode for your system.

Prepared by: Dr. Goutam Majumder

9 of 13

Benefits of Bytecode

  • Platform Independence: As mentioned earlier, bytecode allows Java programs to run on any system with a JVM. This is a major reason for Java's portability.
  • Security: The JVM acts as a controlled environment for executing bytecode, adding a layer of security by restricting direct access to system resources.
  • Performance: While bytecode interpretation adds a step compared to directly running machine code, the JVM can optimize bytecode execution and use JIT compilation for further speed improvements.

Prepared by: Dr. Goutam Majumder

10 of 13

Just-in-time (JIT) Compiler

JIT compilation is a technique used by the JVM to improve the performance of Java programs at runtime. It's not a separate program like javac.

What it does: The JVM interprets bytecode instructions one by one. However, for frequently executed code sections (called "hot spots"), the JIT compiler can intervene and translate that specific bytecode into machine code optimized for your computer's processor. This machine code runs much faster than interpreted bytecode.

When it happens: JIT compilation happens dynamically during program execution. The JVM monitors which parts of the code are used most often and triggers JIT compilation for those sections to improve performance over time.

Prepared by: Dr. Goutam Majumder

11 of 13

The Java Buzzwords

Prepared by: Dr. Goutam Majumder

12 of 13

Prepared by: Dr. Goutam Majumder

13 of 13

Prepared by: Dr. Goutam Majumder

Thank You