'Netbeans Java Build successful but no output

Wrote this simple java code:

public class NewMain {
    public static void main(String[] args) {
        int a;
        a = 5;
        System.out.println("The value of a is" + a);
    }
}

All it gives me is:

run: BUILD SUCCESSFUL (total time: 0 seconds)

What's going on? My Eclipse doesn't do this.



Solution 1:[1]

To run the program:

  • Choose Run > Run Project.

The next figure shows what you should now see.

enter image description here

Solution 2:[2]

I hope this is still relevant. I have Netbeans 9, Go to

run -> set project configuration -> customize.

This would open a new window. In that window in the RUN area, please change Main class to the current file.

Solution 3:[3]

If you are on NetBeans IDE 11.1, just clean and build the project with "Shift+F11" and then run your project with "F6". That will fix your issue. In some cases, merely restarting the IDE can also do the job.

Solution 4:[4]

There are two options availble run the project(F6) and Run the File (Shift + F6).

enter image description here For mine this worked like this (F6)

F6

run: BUILD SUCCESSFUL (total time: 0 seconds)

Shift + f6

 run:
    Welcome to JavaBUILD SUCCESSFUL (total time: 0 seconds)

Solution 5:[5]

It worked for me.

I clicked on : Run->Test Project.

Wait.

Then Run Project.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 L Y E S - C H I O U K H
Solution 2 emrepun
Solution 3 Abhishek Iyengar
Solution 4 Harsha Madusanka
Solution 5 Loc MC