Netbeans Introduction: Create your first Java Program Using NetBeans

NetBeans is an Integrated Development Environment, or IDE, provided free of charge by Sun Microsystems. It's primarily intended for developing software applications in Java, but its' capabilities extend well beyond coding and well beyond Java. It provides design tools, support for other languages, and even a CVS client.

You can get Netbeans (it's free) here: http://www.netbeans.org/downloads/index.html

This tutorial explains how to use NetBeans to create your first Java program.

Step 1 - Create a New Project in NetBeans
Step 1 - Create a New Project in NetBeans

Step 1

Start NetBeans.
Click File / New Project.

The New Project Dialog will appear

Step 2

From Categories, select Java.
From Projects, select Java Application.
Click Next.


Step 2 - Select the Project Type
Step 2 - Select the Project Type

Step 3

Give the project a descriptive name. Don't fall into the nasty habit of accepting the default name.
Note where it is stored so you can retrieve it later.
Change the case-ing of the class name if you like. Camel-humped naming is preferable.

Click Finish.

Step 3 - Name the Project, click Finish
Step 3 - Name the Project, click Finish

Step 4

Your project will look something like the Step 4 screen shot, below.
Note the TODO; replace it with this code:

System.out.println("Hello World");

Be careful; Java is case sensitive. Any variable name, class name, method name, keyword and almost everything else that's not in quotes is case sensitive.

If anything you type appears with a sqiggle beneath it, you may have made a typing error.

Step 4 - Add some code in place of the TODO
Step 4 - Add some code in place of the TODO

Step 5

Click the Green Arrow on the Tool Bar at the top of the window.
Unless you made a typing error, Your project will build and execute.
Note the output in the Output Window at the bottom of the window.

Step 5 - Run the project and note the text in the Output Window
Step 5 - Run the project and note the text in the Output Window

Step 6

Now you will add a class to your project.
Look for the Projects Window at the upper left of the IDE.

Right-Click on the HelloWorld project and select New / Java Class.

Step 6 - Add an empty class to the project
Step 6 - Add an empty class to the project

Step 7

Fill in the name of the new class. In this example it’s called myNewClass.
Select the HelloWorld package from the package drop-down.
Click Finish.

Step 7 - Name the new class
Step 7 - Name the new class

Step 8

Your IDE should look something like this.
Create a method in the class; add the following code.

public void Hello() { 
     System.out.print("Hello from myNewClass");
}

Be careful; Java is case sensitive. Also be sure the method is contained in the class.

Step 8 - Add code to the new class
Step 8 - Add code to the new class

Step 9

Add an instance of the new class to the main( ) and call the method in the new class;
Type the following code:

      
myNewClass myNew = new myNewClass();
myNew.Hello();

Your code should look something like this.

Step 9 - Modify the main() to use the new class
Step 9 - Modify the main() to use the new class

Step Last

Click the Green Arrow on the Tool Bar at the top of the window.

Your project will build and execute.

Note the output in the Output Window at the bottom of the window.

More by this Author


Comments 10 comments

brad4l profile image

brad4l 7 years ago from USA

I think Netbeans is overall a great IDE. After working with it awhile, I do find some of the interface to be a little clumsy, but it is really easy to use and best of all, cross platform :)


nicomp profile image

nicomp 7 years ago from Ohio, USA Author

Thanks, I agree. And it's free!


vijay 7 years ago

good but how can i create tools in netbeans


Sherry Ann Marie  6 years ago

I really appreciate the documentation regarding on how to use Netbeans in doing java applications..thanks a lot!


vinya 5 years ago

thanx for the useful tips.........


chikkku 5 years ago

Superb


Shefali Lachhar 5 years ago

thanks for sharing d topic...it gave me a gud start :)


nicomp profile image

nicomp 5 years ago from Ohio, USA Author

@Shefali Lachhar : Thanks!


@gavin 5 years ago

thanx all clean,

and free,

nice topic for a start ;-)


buvi 4 years ago

Thanks a lot.This is very useful to me.

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working