Friday, September 20, 2013

Programming Java for Absolute Beginners




Step 1: Downloading the Tools

          First go here and download "java netbeans" it is the IDE we will be using. IDE stands for Integrated Development Environment, meaning it is the program where you will do all your coding. Once you've downloaded and installed it, open it up.

Step 2: Understanding the IDE

           When Netbeans opens you will be greeted by the IDE. Now, I know it may seem like a lot to take in, but let me break it down.
At the top of the screen you should see many different icons, the first is "New File" You can use this to create classes and other files, but we will get into this more later. The second icon you will probably use the most, this is the "New Project" icon. The next icon is the "Open Project" icon. You can use this if you made an application on a different computer, and want to open it on a different computer. The next is "Save All", in Java Netbeans you can have multiple projects open at one time, and this allows you to save them all at once. Next is "Undo" and "Redo", they are pretty self-explanatory. The next five are "Build" which compiles your project so you can create an executable of it (A distributable file). Next is "Clean and Build" This cleans all the files in your project. After that is "Run" use this to Run your projects code. Those are the only icons you really need to know. On the right you should see a projects tab, this is where you can access the files of all your applications. Now, that you understand a little more about this IDE, let's get started making this application!

Step 3: Building your Application

        Let's start with a very simple application, the famous Hello World application will do. Now, what we are going to do is have the computer say "Hello World!". To do this create a new project, Click "Next", and call the Project "HelloWorld", leave everything else default and click "Finish". Now, You should be greeted with this code:

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package helloworld;

/**
*
* @author Your name here
*/
public class HelloWorld {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
    }
}



Highlight "// TODO code application logic here" and type System.out.println("Hello World!");

Now, I'm going to explain what we just did. We just told the system to print out "Hello World!" ln means line, so it will print all the words on the same line, try taking it out and see what happens! If you want some more advanced techniques try typing "sout" and press the tab key.

Step 4: Wrapping Up

           I really hope you enjoyed this instructable and took something away from it. Please leave some feedback below if you enjoyed, I really appreciate it! Feel free to check out my other projects if you would like to know a little bit more advanced code. If you would like to see more, just leave a comment. Have a nice day!

No comments:

Post a Comment