Running the Code
To get the code to execute, NetBeans has to be told to run the project. Either use the
Run Main Project command from the
Run menu or click on the green play symbol on the toolbar.
Tip: When a project is executed, NetBeans performs two crucial steps. First, it runs the Java compiler to check that the program is written correctly. The compiler knows all about the syntax of the Java language and if something is not right it will complain. Secondly, it executes the Java code and provides the results in the
Main.java code window a new window called
Output will appear. This is where information about the running of the program and the output from the program will appear. You should see something like:
run: Hello NetBeans World! BUILD SUCCESSFUL (total time: 1 second)
If instead you see a message complaining about something then check to make sure that your Java code looks exactly like the code in the previous step.
Hello NetBeans World! is the string being output from the program. The last line is some housekeeping from NetBeans to say that the project compiled successfully.
That's all there is to it! With most of the simple programs you write all you'll need to know is how to create a new project and how to run it.