Java Introduction tutorial

 Corejava Tutorial

 

coding-zon-core-java

 Table of Contents:

  1. Introduction 
  2. Java Features
  3. Java Architecture
  4. Java program structure
  5. Rules for writing java program
  6. Software Links

 

 

Introduction

Java introduced with the version 1.0 in 1995 by James Gosling who know as father of Java.
Currently, JDK version is Java SE 17. Java is one of the programming language like

C, C++ but there are some drawbacks in C, C++, ex: they are platform oriented.
Java actually developed, to write programs which can be embedded in consumer electronic
devices, such as Fridge, Oven etc., to set automatic timer controls which gives buzzer
automatically after elapsing certain time.
Java invention also made possible exchanging data from heterogeneous websites, because
Java code generates byte code(.class) after compilation. This can understand by any computer.

 

Java Features:

Java has the following features which made it popular.

Java is a Network based language.

Java allows to develop network based applications which can communicate through network.
Such as chatting applications, ecommerce sites...etc.
 

Java is platform independent.

Java program which is developed, compiled on one platform(O/S) can be easily run on another platform.
There are multiple platforms, each targeting a different class of devices:

TOC



  •  Java Card: to be run securely on smart cards.
  •  Java ME (Micro Edition): for devices with limited storage, display, and power capacities. Ex: mobile devices, PDA s, TV set-top boxes, and printers.
  •  Java SE (Standard Edition): For general-purpose use on desktop PCs.
  •  Java EE (Enterprise Edition): Java SE plus various APIs useful for multi-tier client–server enterprise applications. 

Java is secure.

Java provides a rich set of libraries to encrypt information when we are transferring it on the net. 

Scalable: (performance).

One java program can serve to many clients at the same time without degradation in speed. No
matter how many members accessing it.
 

Java is Robust: (fault-tolerant).

It is having a mechanism called Exception handling which can handle all types of errors and
makes program error free.
 

Java is a strongly typed language:

All variables must be declared before they are going to be used in the program.

 Menu

Java Architecture:

coding-zon-java-architecture

 

Java program structure:

class <Classname>
{
    Statement1;
    Statement2;
}


Every Java class enclosed with open curly ‘{‘ , close curly ‘}’ brackets. This is called block.
Inside the block we write statements also called instructions.
ex:

class First
{
       Statement1;
       Statement2;
}


Rules for writing java program:

  •  Every Java program starts with the key word called 'class'.
  •  Java program can be typed in any simple text editor like notepad.
  •  Every Java program contains one default method, called main() method.
  •  Java class name should start with a capital letter.
  •  Need to save with a class name, ex: First.java.

 

Ex:

First.java

public class First 

public static void main(String args[]) {    

     System.out.println("Welcome to Java"); 

   } 

}

 

Every statement in java programs ends with ';' semicolon. If it is removed or not given generates an error.

 

 

 GoTOP

In above program..

Line-1-

First  is the class name.

Line-2 - Contains default method called main ---which starts execution of the program.

public static void main(String args[]){...}

In the above statement..

    public means accessed by anybody outside the class.

    static means available with the class.

    main(String args[]) main is function name.

    args[] String argument passed to that function.
 

Line-3 Contains printing statement, which prints the message on the screen.

 

There are two steps to run java program.  Compiling and Executing.

Compiling     is a process of checking syntactical errors(grammatical)
ex: ‘missing semicolon at line no 10’ etc.,

Once the code is error free, it translates code into byte code, and generates a .class file:

javac is a command for compiling java program.
  

    Syntax: 

    javac <classname.extention>     

    Ex: 

    C:\JavaDemo\javac First.java
 

Executing      Running java program and checking the output.
 

To run and compile, there are several editors available in the market. Once you installed java, you can run the program from command line without any editor.

java → To run the java program.

    Syntax: 

    java <classname>  

    Ex:

    C:\JavaDemo\java First

 

GotoTop Menu

Running at Command Prompt: 

Step-1.

→ Create a folder with some name. ex: c:\JavaDemo

Type the above program in notepad and save it as  First.java  in  c:\JavaDemo.

Step-2.

Open command prompt from the current folder ( c:\JavaDemo) and type
        c:\JavaDemo>javac First.java

Step-3.

If no errors then type the following command to run the code.
        c:\JavaDemo>
java First. 


  coding-zon-jdemo

 Software Links:

1. Java Download:

 Editors: 

2. Netbeans or   Eclipse

3. Path Variables: Create the following path variables in windows and add  it to path variable. Below, versions may vary, based on the latest versions.

ex:
JAVA_HOME=C:\jdk1.8.0_20

ex:
CATALINA_HOME = C:\apache-tomcat-5.5.29

Course Contents


 

 Java Tutorial Home


Comments

Popular posts from this blog

Using javascript pass form variables to iframe src

Creating a new PDF by Merging PDF documents using TCPDF

Import excel file into mysql in PHP