KB 60 Java Quick Start 1
KB 60 Java Quick Start 1
Page 1 of 5
1. 2.
Start NetBeans IDE. In the IDE, choose File > New Project (Ctrl-Shift-N), as shown in the figure below.
3.
In the New Project wizard, expand the Java category and select Java Application as shown in the figure below. Then click Next.
http://testwww.netbeans.org/kb/60/java/quickstart.html
2008-10-03
Page 2 of 5
4.
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. (If you are using NetBeans IDE 6.0, this option is not available.) In the Create Main Class field, type helloworldapp.HelloWorldApp. Leave the Set as Main Project checkbox selected.
5.
Click Finish.
The project is created and opened in the IDE. You should see the following components:
http://testwww.netbeans.org/kb/60/java/quickstart.html
2008-10-03
Page 3 of 5
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.
System.out.println("Hello World!");
Save the change by choosing File > Save. The file should look something like the following:
http://testwww.netbeans.org/kb/60/java/quickstart.html
2008-10-03
Page 4 of 5
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package helloworldapp; /** * * @author Sonya Bannister */ public class HelloWorldApp { /** * @param args the command line arguments */ public static void main(String[] args) { System.out.println("Hello World!"); } }
If the build output concludes with the statement BUILD SUCCESSFUL, congratulations! You have successfully compiled your program! If the build output concludes with the statement BUILD FAILED, you probably have a syntax error in your code. Errors are reported in the Output window as hyper-linked text. Click such a hyper-link to navigate to the source of an error. You can then fix the error and once again choose Build > Build Main Project. When you build the project, the bytecode file HelloWorldApp.class is generated. You can see where the new file is generated by opening the Files window and expanding the Hello World App/build/classes/helloworldapp node as shown in the following figure.
http://testwww.netbeans.org/kb/60/java/quickstart.html
2008-10-03
Page 5 of 5
Now that you have built the project, you can run your program.
Congratulations! Your program works! You now know how to accomplish some of the most common programming tasks in the IDE. Send Us Your Feedback
Next Steps
For a broader introduction to useful IDE features that are generally applicable to Java application development, see Introduction to Developing General Java Applications. To find information specific to the kind of applications you are developing, use the NetBeans IDE learning trail for that type of application. Each learning trail contains a series of tutorials and guides that range in scope from basic to advanced. The following learning trails are available: Basic Java Programming Java GUI Applications Web Applications Java EE Applications Mobile Applications Ruby Applications SOA Applications UML Modeling NetBeans Plug-ins and Rich-Client Applications C/C++ Applications
http://testwww.netbeans.org/kb/60/java/quickstart.html
2008-10-03