This concise tutorial will demonstrate how to develop a Java SE application in NetBeans IDE 6.0. This tutorial assumes that you are familiar with the development of Java applications. During the tutorial, we will demonstrate how to simplify application development with some IDE features.
We will develop a word conversion application that converts multiple English words into one English word. The form of a word is the first letter of the first word, the second letter of the second word, the third letter of the third word, and so on. The generated word is called the clutch word.
Establish a project
The application we create will contain two items:
A Java library project that has a utility class.
A Java application project with the main class that implements the method through the library project.
Note: Strictly speaking, there is no need to create two projects for such a simple application. We use two projects just to demonstrate the functionality required by a more complex application.
First, create a new Java class library to contain the utility classes that you will need to use later. Then, you need to create a new Java application and use it as a master project. After you create the MYAPP project, add the Mylib class to its classpath.
Create a new Java class library
Select File > New Project (ctrl-shift-n). In the Categories option, select Java. In the Projects option, select the Java Class Library, and then click the Next button.
Enter the Mylib in Project Name. Change Project Location to any directory on the computer. In the following, we call this directory netbeans_projects.
Note: The path specified above should appear in the Project Folder field in the wizard as follows:/netbeans_projects/mylib/
Click the Finish button and the Mylib item opens in the Projects window and the Files window.
Creating a new Java application
Select File > New Project. In the Categories option, select Java. In the Projects option, select Java Application, and then click the Next button.
In Project Name, enter the MYAPP. Make sure that Project Location is set to Netbeans_projects.
Enter Acrostic. Main as the main class.
Make sure that the Set as Main Project and the Create main Class check box are selected.
Click the Finish button. The MYAPP project will be displayed in project and Main.java will open in Source Editor.
To configure the Compile class path
Since MYAPP will depend on the classes in Mylib, we must add Mylib to the MyApp classpath. Doing so also ensures that the classes in the MYAPP project can refer to the classes in the Mylib project without causing compilation errors. In addition, this allows you to populate the code based on the MYLIB project using the code completion feature in the Mylib project.
To add a library's utility class to the project classpath:
In the Projects window, right-click the Libraries node for the MYAPP project, and then select Add Project.
Browse to netbeans_projects/, and then select the Mylib project folder. The Project Jar files pane displays the JAR file that you can add to the item. Note that even though we have not actually generated the jar file, the Mylib jar file is also listed. This JAR file will be generated when we build and run the MYAPP project
Click Add Project JAR Files.
Expand the Libraries node. Add the JAR file for the Mylib project to the classpath of the MYAPP project.