Get Started with Java Programming

-- 1 comment
Java is a general-purpose, Object Oriented Programming Language high level programming language. It was developed by Sun Microsystem in 1991. Originally James Gosling, Mike Sheridian, Patrick Naughton start a project named "Green Project". They were developing special software for consumer electronic devices. They name this new programming language as "Oak". The World Wide Web appeared, then they develop a web browser called "HotJava" using the new programming language they developed, which demonstrate the Power the Programming language and it become popular among the internet. They Rename "Oak" into "Java" in 1995.

To run a java code in any machine we need JRE (Java Runtime Environment). JVM is a component of JRE. JVM(Java Virtual Machine). All programming language compilers translate source code into machine code for special computer. However Java first compile the java Source code into a bytecode for a the JVM. Then java interpreter generate the machine specific code. This is why java is Platform Independent. Any code written and compiled in Linux machine could be interpreted and run on Windows machine.

A java source file Hello.java is first compiled using compiler (Javac) which will generate a bytecode Hello.class then Java Interpret(Java) will gives the output. JDK(Java Development Kit)is used for java program development. JRE will be automatically installed when JDK is installed in the system. In Windows machine we need to set environmental variables to run Java or Javac command in Command Prompt. For that Right Click in My Computer and Click properties. Then Click in Environmental Variables. Add "path" as a name and <Location of java installation> in value field in System Variables. The location should be like "c:\program files\java\jdk\bin"

We set up the Environment verialbes now we are ready to go to Run our First Program

1
2
3
4
5
6
7
8
9
class Hello
{
        public static void main(String args[])
        {
                System.out.print("Hello ");
                System.out.println("Java ");
                System.out.println("Welcome to Java");
        }
}

Java contents Packages with any prederined functions and class to use while programming in java. Packages are those refered as Class Libararies in other programming language. While Defining Identifier. Always use UpperCase first character of class and every first Letter of next word without any space. for Functtion name use first lowercase and next word's first character as a UpperCase.
Identifier Examples:-
Class Name:- Hello, HelloJava, WelcomeToJavaProgramming
Method name:- display(), displayMessage(), displayNewMail()

In the above program we use String and System class from Package java.lang We should alway import the package name before using them in our program. But java.lang is a basic package which will be automaticlly inserted.

import java.lang.String will import only that class where as import java.lang.* will import all the classes in that Package. It is better to use .* while during studying purpose but for development we will impor individual package as required.

As java is purely object oriented programming language, we need to create at least one class to run the java program. The main function is automatically called when executing the program. ie the execution of the program starts from the main function. Main function is Public, can be accessed by outer function, Static because no object is created to call the main function. void as it do not return anything. The main function is called using the class name as Hello.main()

String args[] are known as Command line arguments. We could pass arguments to the main function from command line.
Check: Java, General-purpose Programming Language

Prerequisites:- Basic Knowledge of Object Oriented Programming.

Hello This is Sagar Devkota. Studying Bachelor of Software Engineering at Pokhara University. I know something about Linux, Android, Java, Nodejs, Unity3D and 3 dots :)

1 comment: Leave Your Comments

  1. Best No Deposit Bonus Codes in India - Herzamanindir.com
    5 steps1.Visit the official website of No 바카라 Deposit India.
    Benefits of using a no deposit bonus.
    Benefits 바카라 사이트 of 1xbet korean using a no apr casino deposit bonus.
    Benefits of using a no deposit bonus.
    Online Sincere Accessory domain www.online-bookmakers.info

    ReplyDelete