NetBeans is a great little tool for those who build web applications and for software developers. It is an IDE ( Integrated Development Environment ) which is available as open source software. Best of all, you can run this program on most operating systems including Windows, Linux, Mac OS X and Solaris.
What Can It Do?
With NetBeans you can develop applications for use via the desktop or on the web. You can also develop software for use with mobile devices. The applications can be developed with NetBeans using a variety of coding languages including Java, Ruby (with support for Rails), and C/C++. The feature rich software gives you great options and visual abilities that allow you to not only create the applications that you want but to view them and perform testing to work out all of the kinks and bugs in your software.
NetBeans also has a wide array of various plug-ins that are available to developers as well. For a longer list of features and specifications about what this handy tool can do go to: http://www.netbeans.org/features/index.html
Where Can You Get It?
As I have already mentioned, the NetBeans developing software is open source, so you can get it absolutely free. The Full download is going to be about 219 MB; however, if you only want NetBeans for a particular scripting language such as C and C++ or Ruby and Rails then you can download that specific portion of the program and the download will be a lot smaller from around 20-30 MB depending on which application you wish to install.
You can download NetBeans from their site at: http://download.netbeans.org/netbeans/6.1/final
What About Support and Tutorials?
The NetBeans website also offers you tons of information and resources on using NetBeans and learning the basic functions of each of the scripting languages that you can employ with the NetBeans application builder including a quick start guide that you can use to help you get a feel for the use and functionality of building software using NetBeans. The NetBeans community can also offer useful resources for helping you to learn NetBeans as well as offering tools and feedback to help you grow and develop your applications and NetBeans skills.
Setting Up the Project
To create an IDE project:
- Start NetBeans IDE.
- In the IDE, choose File > New Project (Ctrl-Shift-N), as shown in the figure below.
- In the New Project wizard, expand the Java category and select Java Application as shown in the figure below. Then click Next.
- In the Name and Location page of the wizard, do the following (as shown in the figure below):
- In the Project Name field, type
HelloWorldApp
. - Leave the Use Dedicated Folder for Storing Libraries checkbox unselected.
- In the Create Main Class field, type
helloworldapp.HelloWorldApp
. - Leave the Set as Main Project checkbox selected.
- In the Project Name field, type
- Click Finish.
The project is created and opened in the IDE. You should see the following components:
- The Projects window, which contains a tree view of the components of the project, including source files, libraries that your code depends on, and so on.
- The Source Editor window with a file called
HelloWorldApp
open. - The Navigator window, which you can use to quickly navigate between elements within the selected class.
- The Tasks window, which lists compilation errors as well other tasks that are marked with keywords such as XXX and TODO.
Adding Code to the Generated Source File
Because you have left the Create Main Class checkbox selected in the New Project wizard, the IDE has created a skeleton main class for you. You can add the "Hello World!" message to the skeleton code by replacing the line:
// TODO code application logic here
with the line:
System.out.println("Hello World!");
Save the change by choosing File > Save.
The file should look something like the following code sample.
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package helloworldapp; /** * * @author <your name> */ public class HelloWorldApp { /** * @param args the command line arguments */ public static void main(String[] args) { System.out.println("Hello World!"); } }
Compiling and Running the Program
Because of the IDE's Compile on Save feature, you do not have to manually compile your project in order to run it in the IDE. When you save a Java source file, the IDE automatically compiles it.
The Compile on Save feature can be turned off in the Project Properties window. Right-click your project, select Properties. In the Properties window, choose the Compiling tab. The Compile on Save checkbox is right at the top. Note that in the Project Properties window you can configure numerous settings for your project: project libraries, packaging, building, running, etc.
To run the program:
- Choose Run > Run Main Project (F6).
The next figure shows what you should now see.
Congratulations! Your program works!
If there are compilation errors, they are marked with red glyphs in the left and right margins of the Source Editor. The glyphs in the left margin indicate errors for the corresponding lines. The glyphs in the right margin show all of the areas of the file that have errors, including errors in lines that are not visible. You can mouse over an error mark to get a description of the error. You can click a glyph in the right margin to jump to the line with the error.
Building and Deploying the Application
Once you have written and test run your application, you can use the Clean and Build command to build your application for deployment. When you use the Clean and Build command, the IDE runs a build script that performs the following tasks:
- Deletes any previously compiled files and other build outputs.
- Recompiles the application and builds a JAR file containing the compiled files.
To build your application:
- Choose Run > Clean and Build Main Project (Shift-F11)
You can view the build outputs by opening the Files window and expanding the HelloWorldApp node. The compiled bytecode file
HelloWorldApp.class
is within the build/classes/helloworldapp
subnode. A deployable JAR file that contains the HelloWorldApp.class
is within the dist
node.For information on how to run the application from the command line for your operating system, see the "The "Hello World" Application" lesson of the Java Tutorials.