Java Environment Setup

Java Environment Setup

A) Java Environment Setup
> Download Java (JDK) together with Install

> Set Environment Variable (Path variable)

How to laid upwards Path Environment Variable (For Windows 7):
Select Computer epitome on Desktop together with Right click

> Properties

> Advanced System Settings

> Environment Variables

> Select New inwards System Variables

> Enter Variable every bit Path

> Enter Jdk bin directory path (C:\Program Files\Java\jdk1.8.0_40\bin) inwards Value field

> Ok > OK >OK
------------
B) Verify the Java Environment:

 ---------------------------
Launch ascendency prompt
> Type Java (it provides the details)
------------------------------------
Steps:
1) Download Java (JDK) software together with Install

2) Set Environment Variable (Path variable) inwards social club access Java from whatever directory inwards C Drive.

3) Verify the Java Environment setup using coffee or javac commands.
---------------------------------------------
3 steps for writing together with executing Java programs
1) Write Java plan inwards Notepad (Editor)

2) Compile the plan (It creates Class file)

Command prompt > Change to Program file directory

> Type javac Program name.java (java is extension, javac is coffee ascendency for compilation)


3) Run / execute the Program (Output)

> Type coffee infinite Program name
It provides output on the console
--------------------------------------
Sample Java Program:-----------------------------

public class Sample{

public static void primary (String [] args){

System.out.println ("Hello Java World");

}

}
-----------------------------------------------
Note:

i) First missive of the alphabet of the class get upwards should live on upper illustration value

ii) Class get upwards together with plan file get upwards every bit to same.
--------------------------------------------------
Download Eclipse software together with unzip
What is Eclipse (IDE-Integrated evolution environment)?

It is a Platform to exercise together with execute Java programs, Perl, Python, Ruby together with PHP etc...

It provides Editor, Context help, deal for syntax errors, Auto compilation together with debugging.

Open Eclipse primary folder

> Click Eclipse file

It launches Eclipse IDE
-----------------------
Create Java Project
    -> Create a Package
        -> Create Class / Interface
-------------------------------------
Java Program Structure / coffee Syntax

1) Package proclamation statement

ex:

package Saturday;

Note: Package is used to shop together with Organize Classes based on functionality.

It must live on begin inwards our Java Program

2) Import statements

Import statements are kept afterwards the packet statement

We tin strength out import Built inwards together with User defined packages /Libraries

Ex:

import java.io.Console;

import is a keyword to import built inwards / user defined packages

java is Project

io is package

Console is a class inwards io package
-------------------
import java.io.*;

It loads/imports all classes from io package

3) Class proclamation statement

Ex:
public class Sample {
}

public is access modifier

class keyword to declare a class

Sample - get upwards of the Class
-----------------------------

Sumber http://www.gcreddy.com/
Post a Comment (0)
Previous Post Next Post