Java : Programming Language

Introduction:

Java is a high level, general purpose, platform independent, object oriented programming language. Java is simple to learn. It is robust and highly scalable language. It supports multi-threaded programming model and it has a very large set of library to help programmers to write great and complex programs with ease and simplicity.

Java is know to be internet friendly programming language due to it's rich network library which helps to achieve better network related job with very few lines of code. Java was written to supports distributed environment over internet.

Java is suitable to write any kind of programe starting from standalone desktop application, mobile application, web-based application etc. It is not for writing and operating system, device driver, system program like compiler etc.

Java has "write once, run anywhere" principle, which basically mean write one java program source code, compile it and use the compiled bytecode output in any platform without compiling the same source code again for other platform.

History:

In 1990 at Sun Microsystems, Green Team was formed with James Gosling, Mike Sheridan Patrick Naughton and other members to create a new programming language which would be suitable for the smart devices such as set-top box, personal digital assistant etc. This team created a programming language named Oak which become Java later on because Oak was already registered by other technology company.

In 1996, Java1.0 was released while version 1.2, 1.3, 1.4 were released in 1998, 2000 and 2002 respectively. Current version of Java is Java SE 8 and had been released on 18 March 2014.

Getting Started:


Installation:

Java Version Check for pre-installed Java:
Check if your system is already having Java installed or not? Usually Java comes pre-installed on Linux/Unix. To check please open terminal in MacOSX/Linux/Unix [DOS command in Windows] and type following command:

$ java -version

Expected output, if java is pre-installed:
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

If we get version information as output then we have java on our system. We can work with this. But we can further download and install the latest version of Java, if required.

Java Development Kit [JDK] Download:
We can download correct version of Java for our target machine from Java Official Website. The url is given below:
http://www.oracle.com/technetwork/java/javase/downloads/index.html

You can download latest version Java 8 SE directly from below given url-
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

To install, we simply double click on the dmg/rpm/exe file to start installer and then follow the steps.

You can further read installation instructions from Java's official web-site:

Do not get confused with JDK and JRE. JDK is standard software development kit while JRE is java runtime environment. JRE is needed to run java byte-code [complied product of java source code] while JDK is needed to compile our java code.

First Java Program: "Hello World"

We can use any editor to write Java program like Xcode, Eclipse, NetBeans, BlueJ, jEditor, TextWrangler, Notepad, Notepad++, Emacs etc. You can choose your own IDE though our recommendation is Eclipse.

Lets create a file named "hello.java" and type down the code given below and save it.

class HelloWorld {

public static void main(String[] args) {
// Prints the string to the console.
System.out.println("Hello World!");
}

}

We can compile and run the code according to the IDE provide GUI interactions means pressing buttons to Compile and Run on IDE window usually but here we would like to do using commands on command prompt.

To compile use javac command:
$ javac hello.java

To run the compiled java byte-code java command:
$ java hello HelloWorld

This will print Hello World! on console as output of the program:
Hello World!

References:
  1. https://en.wikipedia.org/wiki/Oak_(programming_language)
  2. http://www.oracle.com/technetwork/topics/newtojava/overview/index.html
  3. https://en.wikipedia.org/wiki/Java_(programming_language)