Java tutorial for beginners - Part 1
Free Java Guide
Programming Tutorials
These tutorials will introduce you to Java programming Language. You'll compile and run your own Java application, using
Sun's JDK. It's extremely easy to learn java programming skills, and in these parts, you'll learn how to write, compile, and
run Java applications. Before you can develop corejava applications, you'll need to download the Java Development Kit
(JDK).
History of Java
SCJP Notes 1
Java Online Training
SCJP Notes 2
Core Java Training Courses by Industry Experts. Join us Now
Free JAVA Tutorials
SCJP Notes 3
SCJP Notes 4
PART-1
SCJP Notes 5
Java Hello World Program
Java Comments
Java Data and Variables
Java Command Line Arguments
SCJP Notes 6
SCJP Notes 7
SCJP Notes 8
Java Test
Java Hello World Program
JDBC Program Tutorial
Java Swing
Java Source Code
Java Applet
Java Servlet
JavaServer Pages
Criticism of Java
Our first application will be extremely simple - the obligatory "Hello World". The following is the Hello World Application as
written in Java. Type it into a text file or copy it out of your web browser, and save it as a file named [Link]. This
program demonstrates the text output function of the Java programming language by displaying the message "Hello
world!". Java compilers expect the filename to match the class name.
Study in Germany
Find Top Colleges in Germany. Get Info on Admission,Visa,Scholarships
SQL Tutorial
PLSQL Tutorial
PLSQL Examples
HTML Tutorial
A java program is defined by a public class that takes the form:
public class program-name {
What is XML?
optional variable declarations and methods
XML Tutorial
public static void main(String[] args) {
statements
}
Job Interview Questions
Java Interview
SQL Interview
optional variable declarations and methods
XML Interview
}
HTML Interview
Partner websites
Source Code
Bird Watching
Haryana Online
Asia Newscast
North India Online
In your favorite editor, create a file called [Link] with the following contents:
/** Comment
* Displays "Hello World!" to the standard output.
*/
class HelloWorld {
public static void main (String args[]) {
[Link]("Hello World!");
//Displays the enclosed String on the Screen Console
}
}
To compile Java code, we need to use the 'javac' tool. From a command line, the command to compile this program is:
javac [Link]
For this to work, the javac must be in your shell's path or you must explicitly specify the path to the program (such as
c:\j2se\bin\javac [Link]). If the compilation is successful, javac will quietly end and return you to a command
prompt. If you look in the directory, there will now be a [Link] file. This file is the compiled version of your
program. Once your program is in this form, its ready to run. Check to see that a class file has been created. If not, or you
receive an error message, check for typographical errors in your source code.
You're ready to run your first Java application. To run the program, you just run it with the java command:
java HelloWorld
Sample Run
Hello world!
The source file above should be saved as [Link], using any standard text editor capable of saving as ASCII
(eg - Notepad, Vi). As an alternative, you can download the source for this tutorial.
[Link]
Note: It is important to note that you use the full name with extension when compiling (javac
[Link]) but only the class name when running (java HelloWorld).
You've just written your first Java program! Congratulations!!
Next: Java Comments
Part 1 of 5
Previous
Copyright 2006-2013 Free Java Guide & Tutorials. All Rights Reserved.
Next