The Best Technical Blog Ever


Java Tutorial

Java Overview

This blog will introduce you to the basic concepts of objects, classes, inheritance, interfaces, and packages. This focuses on how these concepts relate to the real world, while simultaneously providing an introduction to the syntax of the Java programming language.

What is Java

Java was developed by James Gosling at sun Microsystems. Java is a high-level , robust, secured, platform independent and object-oriented programming language. Program developed in Java can be executed on any system (i.e) runs on any operating system such as Windows, Mac OS, and the various versions of UNIX. The reason it can run on any operating system is because of the Java Virtual Machine. Java has its own runtime environment (JRE) and API, it is called platform. Java is guaranteed to be Write Once, Run Anywhere.

Java files are stored with .java extension. These files are compiled into Java byte code using the Java compiler, then byte code is executed using the Java Virtual Machine (JVM). The Java compiler and the JVM are part of the Java Development Kit.

Java Bytecode

Java programs written in the Java language are compiled into Java bytecode which is stored in binary format with .class file exatension. Afterthat it can be executed by the Java Virtual Machine.

Java Virtual machine (JVM):

To run a Java program, the java compiler converts the source code into Intermediate code called bytecode. Java Virtual machine (JVM) interprets the byte code into the machine code depending upon the underlying operating system and hardware combination. It is responsible for all the things like garbage collection, array bounds checking, etc…. JVM exists only inside the computer memory. The machine code is generated by Java interpreter by acting as an intermediary between the virtual machine and real machines. JVM is platform dependent. The Java Virtual Machine is implemented for different operating systems like Windows, Mac OS, Linux, IBM mainframes, Solaris etc. Thus, if your Java program can run on a JVM on Windows, it can also run on a JVM on Mac OS or Linux. The Java Virtual Machine is a program itself. You start up the JVM and give it what Java code to execute. This is typically done via a command line interface (CLI). On the same command line, you tell the JVM what Java class (bytecode) to execute.


Java APIs:

  1. Java compiler
  2. Java Virtual Machine (JVM)
  3. Java Application Programming Interface (API)

Java Runtime Environment (JRE)

The JRE consists of the Java Virtual Machine (JVM), Java platform core classes, and supporting Java platform libraries. The Java Runtime Environment (JRE) is the Java Virtual Machine and the standard Java APIs coming with Java Standard Edition (JSE). The Java Runtime Environment (JRE) is part of the Java Development Kit (JDK), a set of programming tools for developing Java applications. It provides the minimum requirements for executing a Java application; but not to compile it. It is the runtime portion of Java software, which is all you need to run it in your Web browser.

Java Software Development Kit (Java SDK)

The Java Software Development Kit (Java SDK) is the JRE with the Java compiler, and a set of other tools. To develop Java programs,The JRE is not enough then you need the full Java SDK. Only the full Java SDK contains the Java compiler which converts your .java source code files into byte code .class files. In addition, some Java servers may need some of the tools in the JDK to compile it [e.g.JSPs (Java Server Pages)] into Java byte code. In that case, it is not enough to run the server with the JRE. You must use the full Java SDK so the server has the extra tools from the Java SDK available.

How program executes in Java

To write your java program, you will need:
  1. The Java SE Development Kit 8 (JDK 8)
  2. A text editor- like notepad
For creating java program
  1. Create a source file:
    A source file contains java code, that programmers can understand. You can use any text editor to create and edit source files. Programmer write the code (source code) in a text editor with the file extension .java.
  2. Compile the source file into a .class file:
    The Java programming language compiler takes your source file and using javac command it validates the code and translates it into bytecodes that the Java virtual machine can understand. This is known as compiling. The byte code for each public class is placed in a separate file with the extension .class.
  3. Run the program:
    Once the class file has been created, the Java runtime system can easily find it to run.

Keypoints to remember in java

1. Java is a high level, robust, secured , platform independent and object oriented programming.... more info

Back to Basics:- Java Syntax

In this session, you are going to refresh some basic set of rules(java syntax), defining how a ... more info

Total Visits
Traffic feed status