Java 101: Introduction to Java

Brief History

Java is one of a popular object-oriented programming language that was released to the public on May of 1995. The main idea for the Java programming language is “write once run everywhere” or WORA for short.

It was created by James Gosling and his team at Sun Microsystem. Java Was originally named Oak. Oracle acquired Sun Microsystem on 2010.

Java main features

  • Platform independent
  • Simple
  • object oriented
  • robust
  • secure
  • high performance
  • multithreaded
  • Familiar
  • Flexible

Other than that

  • Java has large community where getting support is easier.
  • reliable development tools like NetBeans, eclipse and other tools
  • huge array of open source libraries to choose from. Most of the libraries are specific for complete task. incorporate into your application makes faster cutting extra development time.
  • frameworks like struts, Spring, hibernate, GlassFish for faster development process.

Editions

Java SDK comes in has few editions which support different environment where the application runs.

Micro Editions, Java ME
development tool to build java application that run in an environment with limited resources, for example, embedded systems and mobile devices.
Standard Edition, Java SE
Development tool that consist of most basic yet enough to build java application. Other editions are based on this standard edition. Use to build application for personal computers or servers.
Enterprise Edition, Java EE
for distributed system across internet technology. Web application, services and scripting languages in addition with standard tools. Allow programmer to build servlets and server pages.

Version of Java

  • DK 1.0
  • JDK 1.1
  • J2SE 1.2
  • J2SE 1.3
  • J2SE 1.4
  • J2SE 5.0
  • Java SE 6
  • Java SE 7
  • Java SE 8
  • Java SE 9
  • Java SE 10
  • Java SE 11
  • Java SE 12
  • Java SE 13

Java Technology

Java Development Kit, JDK
JDK is an environment which allows Java Developer to develop java application or applets. It consists of Java Runtime Environment, set of libraries called API (jar files), Development tools such as Javac (Compiler), java (interpreter/loader), jar (archiver), Java Runtime Environment, JRE files.
Java Virtual Machine, JVM
JVM is an logical machine that provides runtime environment for java bytecode.
Integrated Development Environment, IDE
Source Code is a text files that contains java code or instructions. It can be written using text editors like notepad, notepad++, Sublime, Atom. Source code ends with java extension. IDE integrates the editors and Java Development tools for easier and faster development. Following are widely used IDEs for Java NetBeans, Eclipse, IntelliJ Idea and Android Studio.

** Disclaimer this work is not intended to promote any products although all of them are free to use. User option may depend on project team needs.

Development process

Designing program

Developer understands the problem statement. Runs necessary reading and comes with solution such as UML diagrams like class diagram, use cases and activity diagrams depending on project need.

Writing Java source code

Programmers translate the program design to source code with current syntax in text editor or IDE. This process also involving creating resources, integrate supporting resources. this process repeated process where programmer try to fix errors encountered during writing of the program.

Compiling a java program

Bytecode is compiled java source code file. File ends with class extension. The Jar files consist of these. Bytecode needs JVM to execute. Its partially compiled program, JVM interprets these byte codes to run the program by compiling them to machine code “Just In time” by JIT compiler (Just in time compiler).

The Syntax

Java coding style is highly influence by C and C++ programming languages. For example, simple line comment uses the double slash // and multiline comment begins with /* and ends with */. In addition to that, java introduce Javadoc comment that begins with /** and ends with */

Unlike C++, Java don’t support operator overloading and multiple inheritance Java is pure OOP, all code written inside Class element, this makes every element in java application an object. Primitive data type like Boolean, int, float, double and char however are not object.

The Hello World program

To demonstrate how simple program like hello world program is written using java. This program is written using Notepad++ text editor.

source code for hello world program

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

Compile the source using command prompt. Change the directory path to your project folder containing the source code. In this example, the path is c:\javaBlog\unit1 ,use the javac command to invoke compiler

c:\javaBlog\unit1>javac HelloWorld.java

This command is followed by the source code filename with its extension. the compiler will process the file and create a byte code. Bytecode extension is .class as shown below. The byte code will be added to your project folder.

c:\javaBlog\unit1> dir
HelloWorld.class
HelloWorld.java

Running the program using the java command. This will cause the bytecode passed to this program to be interpreted. Notice that the file extension is not specified. The hello world program outputs the text on console as shown below.

c:\javaBlog\unit1>java HelloWorld
Hi, Hello World

This is rather an easy and straight forward program. The steps are repeated if compiler produces compile time error as follows. This error is caused by wrong character is used to write a string.

A post by Cuber

Comments

Popular posts from this blog

Drawing Simple Pie Chart

VB.net connecting to SQL Server

VB.net