Hello friends!
If you
are interesting in learning JAVA, you can start from here.
I am going
to explain, how to start writing JAVA programs.
So First
of all I am going to tell the things you need to set-up before writing and run
any JAVA program on your machine.
For
Running any JAVA program on your system you need to install JAVA SDK and JRE.
JDK (Java Development Kit) :-
Java Development Kit (JDK) is a program development
environment for writing Java applets
and applications. It consists of a runtime environment as well as the tools and
programming that developers need to compile, debug, and run applets and
applications written in the Java language.JDK provided by sun Microsystems. Java
Development Kit or JDK comes in various versions and can be downloaded free
from the sun Microsystems.
JDK also known as Java 2 Platform That comes in three editions J2ME,
J2SE & J2EE. As a beginner start by downloading J2SE.
Acronyms:
- JDK - Java Development Kit
- JVM - Java virtual machine
- JRE - Java runtime environment
- Right click on the My Computer icon on your desktop and select properties
- Click the Advanced Tab
- Click the Environment Variables button
- Under System Variable, click New
- Enter the variable name as JAVA_HOME
- Enter the variable value as the install path for the Development Kit
- Click OK
- Go to path variable and put their “installation path of JDK/bin”.
- Click Apply Changes
Static means it does NOT reset variable values each run through(not automatically anyways)
Void means (as far as i know, but i could be wrong), it has no specific type(such as integer, string, double etc)
Main is just the event so the computer knows where the actual code it should run through is.
You can download JDK from http://java.com/en/download/index.jsp
Installing JDK :-
Its very simple to install JDK-
1. Install
the downloaded JDK setup.
2. Set
the envirinment variables in system-
Now we are going to create our first JAVA program “Hello JAVA World”
This program will show one message---
We will create this program in notepad , From next time we will start
working on Eclipse IDE.
1.
Open your notepad and write a JAVA class like below code
//First Simple
java application
public class HelloJavaWorld
{
public static void main (String [] args)
{
System.out.println("Hello JAVA World!! This is my first program.");
}
}
Save the file as "HelloJavaWorld.java"
Always save the file by the class name
which you have given in the program and you have to use the .java extension
Run the Program
Open command prompt go in the drive (where you save your notepad
file)
And type the command to compile your .java to .class
javac HelloJavaWorld.java
now run your .class file
java HelloJavaWorld
And you will
see the message “Hello JAVA World!! This is my first program.” On console.
Here all what you did and why!
Following that is the beginning of your program class definition:
public class HelloJavaWorld {
The public keyword, used as a
modifier that describes class is public and other classes can use the class.
The next line of code starts the main() method
definition.
public static void main(String
args[]) {
Methods are groups
of statements that are executed by your computer when
instructed to do so.
Public means it can be
accessed from anywhere.
The one statement inside the main() method, which is your next line of
code,
instructs your computer to say hello to the world.
System.out.println("Hello JAVA World!! This is my first program.");
This is actually a call to a method that handles your system's standard output. It
prints one line to the screen.
_________________________________________________________
***********************Keep studying and enjoy***********************