user623990
user623990

Reputation:

Building and running a java application from Netbeans

I've recently started using NetBeans, coming from Eclipse.

I have a simple implementation of SnakeYaml (a yaml parser for java) I am trying to test. It is contained in a main method.

When I try to run it (F6) like I would in Eclipse, I get a successful build but no output. Instead, to run my program, I need to first build (F11), then run (F6). Is there a way for my project to be automatically built when I try to run it.

Note: Netbeans actually tells me I don't have to build to run from inside the IDE, but it seems to be lying.

Upvotes: 1

Views: 8800

Answers (3)

Akshat
Akshat

Reputation: 267

  1. Make Sure that the class lies in the project's package.
  2. main() method should be having the correct lines which are to be executed.

Upvotes: 0

mKorbel
mKorbel

Reputation: 109815

@MaxMackie not an answer

1) project -> properties -> compiling -> Compile on Save - mark checked

2) project -> properties -> Run -> select main.class (because your project can contains tons Java Classes that contains main method too)

last property is to set current project as main project (i never ever to needed to check or set that) and check tools -> options -> keymap

enter image description here

Upvotes: 1

stratwine
stratwine

Reputation: 3701

Use Shift+F6 or Run-->Run File(when the Class with the main method is opened and in the current editor)

Upvotes: 0

Related Questions