How to Make a Hello World Program in Java
This is the first post in my "new" blog. Actually, this blog was a mixed Niche which has no clear topic. Build in 2010 and has mo...
http://ww-tikus.blogspot.com/2015/01/how-to-make-hello-word-program-in-java.html
This is the first post in my "new" blog. Actually, this blog was a mixed Niche which has no clear topic. Build in 2010 and has more than 1000 posts, this blog has no significant results in page views. It just has 1000 page views in a day.
But now i decided to delete all of the posts and i want to make this blog is just about technology. In this tutorial i will show you how to make a simple Hello World in Java. What is Hello World?
But now i decided to delete all of the posts and i want to make this blog is just about technology. In this tutorial i will show you how to make a simple Hello World in Java. What is Hello World?
In Programming world, the people must be familiar with Hello World. Hello World is a simple two words that usually is used to learn your first programming. Usually, at the first learning about programming language, we make a program that print "Hello World" in the screen. In this post, i will show you how to make a simple Hello World program that make in Java Language.
Before you can compile and run the program, make sure your Environment compliance with Java language by install Java Development Kit (JDK).
public class HelloWorld {public class HelloWorld is the identity of your class file. Notice this name must be same as your file name. If you use above code, so you must save your file as HelloWorld.java
public static void main(String[] args) {
System.out.println("Hello, World");
}
}
public static void main(String[] args) is called as main method. This method is related to what the program will do. This method may call the other method to execute it, or just execute some code inside this method. This method usually has "String[] args" inside the bracket to make some working parameter while running a compiled program. The further explanation about java programming will be explained in the future post.
System.out.println("Hello, World"); is used to show Hello World string in the screen. System.out.println will show anything inside the bracket and make a line break in the end.
In Java programming language, you will notice open bracket '{' and closing bracket.'}'. If there is one open bracket, then there is must be one closing bracket to close it. In above case, you will see two open bracket and two closing bracket.
The brackets will define the border of the codes. Refer to the above codes, the codes in the inside bracket is define main method, and the codes in the outside is define the codes of class HelloWorld.
Compile & Run
If you have make your Java file (HelloWorld.java) and make your Hello World codes like the above sample of codes, you can compiled and run the program.
If you use Command Prompt, you can compiled it with :
javac HelloWorld.javaMake sure the path in your Command Prompt is same as the location of the HelloWorld.java.
After that you can run the program with this command :
java HelloWorldAnd now you will see 'Hello World' output in your Command Prompt.