Once we have created some code as a part of our application, the next stage is to run the code. NetBeans allows developers to run either a file (with a main
method) or a project. In this recipe, we'll see how this can be achieved.
It is necessary to have a project in order to run a file. If you are unsure on how to create a project, please check the recipes in Chapter 1, Using NetBeans Projects. To help follow this recipe, when creating a project, enter RunningFiles
as the project name and ensure that the Create Main Class option called com.davidsalter.cookbook.runningfiles.RunningFiles
is selected.
Right-click on the
RunningFiles
project, and select New and Java Class….On the New Java Class window, type
Application
under the Class Name field.On the package selection, enter
com.davidsalter.cookbook.runningfiles
.Edit the
Application.java
file and add amain
method:public static void main(String[] args) { System.out.println("This is called from Application...