This is the first article of w3resource's Java programming tutorial. The aim of this tutorial is to make beginners conversant with Java programming language.
Introduction to Java programming language
Today Java programming language is one of the most popular programming languages which is used in critical applications like stock market trading system on BSE, banking systems or android mobile application.
Java was developed by James Gosling from Sun Microsystems in 1995 as an object-oriented language for general-purpose business applications and for interactive, Web-based Internet applications. The goal was to provide a platform-independent alternative to C++. In other terms, it is architecturally neutral, which means that you can use Java to write a program that will run on any platform or device (operating system). Java program can run on a wide variety of computers because it does not execute instructions on a computer directly. Instead, Java runs on a Java Virtual Machine (JVM).
Java is a general-purpose programming language that’s used in all industries for almost any type of application. If you master it, your chances of getting employed as a software developer will be higher than if you specialize in some domain-specific programming languages. The Java language is object-oriented (OO), which allows you to easily relate program constructs to objects from the real world.
History of Java Releases
This program runs fine under GNU Gcc compiler. We have tested this on a Ubuntu Linux system. But if you are using any other compiler like Turbo C++, the program needs to be modified to be executed successfully. For the sake of simplicity, we have not included that additional stuff here.
|Java Version/CodeName||Release Date||Important Features/Code Name|
|JDK 1.0 (Oak)||23rd Jan 1996||Initial release|
|JDK 1.1||19th Feb 1997||Reflection, JDBC, Inner classes, RMI|
|J2SE 1.2 (Playground)||8th Dec 1998||Collection, JIT, String memory map|
|J2SE 1.3 (Kestrel)||8th May 2000||Java Sound, Java Indexing, JNDI|
|J2SE 1.4 (merlin)||6th Feb 2002||Assert, regex, exception chaining,|
|J2SE 5.0 (Tiger)||30th Sept 2004||Generics, autoboxing, enums|
|Java SE 6.0 (Mustang)||11th Dec 2006||JDBC 4.0, java compiler API, Annotations|
|Java SE 7.0 (Dolphin)||28th July 2011||String in switch-case, Java nio, exception handling new way|
The Java Program Life Cycle
Java requires the source code of your program to be compiled first. It gets converted to either machine-specific code or a byte code that is understood by some run-time engine or a java virtual machine.
Not only will the program be checked for syntax errors by a Java compiler, but some other libraries of Java code can be added (linked) to your program after the compilation is complete (deployment stage).
Step1 : Create a source document using any editor and save file as .java (e.g. abc.java)
Step2 : Compile the abc.java file using “javac” command or eclipse will compile it automatically.
Step3 : Byte Code (abc.class) will be generated on disk.
Step4 : This byte code can run on any platform or device having JVM (java.exe convert byte code in machine language)
Let’s get familiar with various terminologies used by java programmers.
JDK (Java Development Kit) : JDK contains JRE along with various development tools like Java libraries, Java source compilers, Java debuggers, bundling and deployment tools
JRE (Java Runtime Environment) : It is part of JDK but can be used independently to run any byte code (compiled java program). It can be called as JVM implementation.
JVM (Java Virtual Machine) : ‘JVM’ is software that can be ported to various hardware platforms. JVM will become an instance of JRE at runtime of java program. Byte codes are the machine language for the JVM. Like a real computing machine, JVM has an instruction set which manipulates various memory areas at run time. Thus for different hardware platforms, one has corresponding the implementation of JVM available as vendor supplied JREs.
Java API (Application Programming Interface) : Set of classes’ written using Java programming language which runs on JVM. These classes will help programmers by providing standard methods like reading from the console, writing to the console, saving objects in data structure etc.
Advantages of Java programming language
In next session, we will discuss how to install JDK, Eclipse (IDE) and the basic structure of Java program. Compiling, running and debugging java program.
Solve these problems: