1

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.

0

3 Answers 3

1

@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

Sign up to request clarification or add additional context in comments.

10 Comments

Did both, however I still need to build before seeing different output.
question: are you imported this project from WorkSpace (eclipse), then to try Re-Synchronize Eclipse Project
No, this project was made from scratch in Netbeans.
there must be another problem (betweens hands & head) please take this code stackoverflow.com/q/8249353/714968, and set that as main class, hmmm maybe ... but I still use version 6.9.1, I'm surprised, because NetBean is anti-technocrati IDE, created for total lazy coders, that can't care about nothing
I'm using version 6.8 on Linux if that makes a difference.
|
0

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

2 Comments

maybe you could try setting Run --> Main Project --> None as suggested here and then try this ?
Still getting old output, I need to re-build to see changes.
0
  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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.