Book Image

NetBeans IDE 8 Cookbook

By : David Salter, Rhawi Dantas
Book Image

NetBeans IDE 8 Cookbook

By: David Salter, Rhawi Dantas

Overview of this book

<p>From the start to the end of a Java project's lifecycle, this book will show you how to perform many key tasks with the NetBeans IDE, uncovering more about mobile, desktop, and enterprise Java along the way.</p> <p>You will start by creating Java projects and learning how to refactor and use NetBeans tools to increase developer efficiency. You will then get a walkthrough of how to create a desktop application before covering JavaFX and mobile applications and how to use external services within them. Having seen how to create many different types of applications, you will then be shown how to test and profile them before storing them in revision control systems such as Git or Subversion. Finally, you will learn how to extend NetBeans itself by adding new features to the IDE.</p>
Table of Contents (19 chapters)
NetBeans IDE 8 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Running a file


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.

Getting ready

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.

How to do it…

  1. Right-click on the RunningFiles project, and select New and Java Class….

  2. On the New Java Class window, type Application under the Class Name field.

  3. On the package selection, enter com.davidsalter.cookbook.runningfiles.

  4. Edit the Application.java file and add a main method:

    public static void main(String[] args) {
      System.out.println("This is called from Application...