|
||||||||
Netbeans Basics --modified from netbeans.orgnote: Your latest version may look different --see netbeans.org for latest getting started documents. Setting Up the ProjectTo create an IDE project
The project is created and opened in the IDE. You should see the following components:
Adding Code to the Generated Source FileBecause 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 herewith 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 ProgramBecause 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:
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 ApplicationOnce 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:
To build your application:
You can view the build outputs by opening the Files window and expanding
the HelloWorldApp node. The compiled bytecode file |
||||||||
© Lynne Grewe |