In order to write your first Java Program, you require :
1. JDK installed on your computer.
You can install it from here :
http://www.oracle.com/technetwork/java/javase/downloads/index.html
2. Setting of environmental variable path.
3. A simple text editor.
First Java Program - Hello World!
The code looks like this :
Note : All the java programs must be saved with the name equal to classname with an extension .java.
Now for compiling open the command prompt and go to the location of your file in which the java code was saved and type :
javac Hello.java
and press enter.
If nothing happens it means the program is correct or not containing any error.
Now you need to Execute the program and for executing just type :
java Hello
and press enter
Now you can see that the output is "Hello World!" shown in the cmd.
EXPLANATION OF PROGRAM :
The code is shown as :
public class Hello
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
Since java is based on object oriented concepts, hence all the code must be stored in a class.
In above i am taking a class named "Hello" . You can use any name but make sure that the code is stored with the same name as that of the class . This is because when the code is compiled using java compiler then a class file (which contain byte codes) is created with the same name as that of your file name.
And when you execute your program then the JVM (Java Virtual Machine) search for the class file and by using the name of class file it finds your program.
So, we can say that the name of file is same as that of the class name because JVM easily linked the class file with program file.
Now in the class there is a main method, which starts the execution of program.
In main method "public" is used as access specifier.
"static" is used because we want the main method should be run without making the objects of the class.
"void" is used because method is not return anything.
and parameters is passed as "String[] args" for handling the input given by user, which is not used in this program.
"System.out.println()" method is used for writing the output on the screen.
great article. Thanks for sharing java Programming .its really helpful for me.java is the one of the most programming language build up on api....keep sharing on updated java tutorials?
ReplyDeleteBest MCA
ReplyDeletecolleges in noida
Best MSC IT
colleges in noida
Best M
TECH colleges in noida
I found best article.thank you for sharing useful info.
ReplyDeletevisit
web programming tutorial
welookups
ReplyDeleteorganic cold pressed oils
natural cold pressed oils
organic oil
natural oil
pure herbal oil
ayurvedic oil store in jaipur
ayurvedic oil
ReplyDeleteorganic cold pressed oils
natural cold pressed oils
organic oil
natural oil
pure herbal oil
ayurvedic oil store in jaipur
ayurvedic oil
Excellent post and very useful for everyone .
ReplyDeleteThe Best college in Jaipur
Really nice experience you have. Thank you for sharing. It will surely be an experience to someone.
ReplyDeletepython course institute in bangalore
python Course in bangalore
python training institute in bangalore
Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
ReplyDeleteSelenium training in Chennai | Selenium training institute in Chennai | Selenium course in Chennai
Selenium training in Bangalore | Selenium training institute in Bangalore | Selenium course in Bangalore
Selenium interview questions and answers
Selenium training in Pune | Selenium training institute in Pune | Selenium course in Pune
Very interesting blog!!! I learn lot of information from your post. It is very helpful to me. Thank you for your fantastic post. please visit
ReplyDeleteCCTV Camera in jaipur at Rajasthan
Home security system in jaipur
Wireless Home Security System in jaipur
Realtime attendance machine in jaipur
CCTV Camera dealer in jaipur
Hikvision DVR in jaipur at Rajasthan
security system solutions in jaipur
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
ReplyDeletewebsite: geeksforgeeks.org
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
ReplyDeletewebsite: geeksforgeeks.org
A Computer Science portal for geeks. It contains well written, well thought and well
ReplyDeleteexplained computer science and programming articles, quizzes and practice/competitive
programming/company interview Questions.
website: geeksforgeeks.org
A Computer Science portal for geeks. It contains well written, well thought and well
ReplyDeleteexplained computer science and programming articles, quizzes and practice/competitive
programming/company interview Questions.
website: geeksforgeeks.org
Such a great information for blogger iam a professional blogger thanks…
ReplyDeleteUpgrade your career Learn Oracle Training from industry experts gets complete hands on Training, Interview preparation, and Job Assistance at Softgen Infotech.
The information you gave is useful for us for project details click here MSc Computer Science Project Topics in Android , MSc Computer Science Project Topics in Asp.Net , CSE Mini Projects , CSE Projects for Final Year , CSE Mini Project Topics , CSE Final Year Project Domains
ReplyDeleteYour blog has some decent value. Thanks for keeping it up!
ReplyDeleteنقاط تراعى عند سحب الأموال
I really appreciate coming across your blog.
ReplyDeleteموقع اسواق ديلي
You have some really nice content on your blog.
ReplyDeleteتعليم التداول للمبتدئين