How to Write Your First Java Application

So, you want to learn Java programming - a great idea! You may need at least a couple of years before you will be able to produce
commercial quality applications, but these years will pass anyway, so why lose the opportunity of adding a great programming language
to your skill set?

First, you will need a computer that has the Java platform installed on it. I know, "Java platform" sounds a bit too techie, right?

Actually, it only consists of two components:

- JRE, the Java Runtime Environment, which is needed to run the Java applications.
- JDK, the Java Development Kit, which is needed to build Java applications.

Most people will only have to install JRE, because they don't develop software, right? On the other hand, programmers will only need
to install JDK, because it includes JRE as well.

But first, let's determine if JRE is installed on your computer. For Windows, open the command prompt, and then type in the following
command:

java -version

If JRE is installed, you will see a message that looks like this.
My Blog
Next article: Key Reasons why Java is the Best Programming Language in the World
If JRE is missing, you will get the "Bad command or file name" error message.

Well, don't worry, even if you are getting the error message. We are going to install JDK, which includes JRE as well, so we will fix the
problem right away.

Begin by visiting this website page:

http://www.oracle.com/technetwork/java/javase/downloads/index.html

Scroll down until you see the "Java SE Development Kit (JDK) Cobundles" link, and then click "JDK 8 with NetBeans".

You can find versions for Linux, Mac OS X and Windows. If you are a Windows user, my recommendation is to download the Windows
x64 version, which will run faster on all the modern computers.

Download the installation kit, and then run it.

Start NetBeans, and then choose a new Java project, just like in the picture below.
We are going to create a "Hello Word" application, a program that will display the text within the quotes in a small window.

Why have I chosen to do that? Most programmers create "Hello World" applications, because they are easy and can quickly show if a
particular programming language is complex or simple.

If a programming language needs dozens of codes to display a simple message, it's either written in Assembly, or too complex for a
beginner.

With Java, we will only need five lines of code (OK, we've got six lines is you also count the comment line, the one that starts with //).

So, give your project a name ("HelloWorld" might be a good idea), and then set its location. Press the "Finish" button to have NetBeans
generate the needed files.

Paste the code below in the project window, and that is it!

public class HelloWorld {
   public static void main(String[] args) {
      // Displays "Hello, World" on the screen
      System.out.println("Hello, World");
   }
}

Choose Run -> Run Main Project, and you should see the following image.
If everything worked well, you can proudly call yourself a Java programmer now! And if things don't work as expected, it's probably
because you haven't typed in the code exactly as I wrote it above.

Try to copy/paste those lines of code to make sure that everything works OK. And it's important to remember that Java is a case-
sensitive programming language, so HelloWorld and Helloworld are two different classes.

Most of all, have fun trying to code as many simple applications as you can. This is by far the most efficient way of learning
programming, and NetBeans comes with several examples that you can try and learn from. Here's a link to their (slightly more complex)
"Hello World" example.
Copyright © Java Pro News.  All Rights reserved