Java – I cant print a simple JAVA code with BlueJ , works in CMD

bluejjavaprinting

I am new to java, and I can't seem to figure out how I can get this simple code to work properly. I understand the code, and I have it typed exactly how the book has it. The code compiles with no errors, but it just doesn't print anything. I think the problem has to do with the main function or something, because when I right click the class in BlueJ and click on void main it will compile correctly.

Anyways, here's the code.

 public class Test
{
   public static void main(String[] args)
   {
     System.out.println("Hello World!");
   }
}

Am I doing something wrong in BlueJ, or is it supposed to be that way? Thanks!

Best Solution

When you're ready with the code, click on the Compile button.

first screen

If everything is fine, you will see a message on the bottom of the screen, saying Class compiled - no syntax errors. Then close the screen and go back to the project palette.

Right click on the class, and pick void main(String[] args). You will be prompted with a little screen, where you can provide some parameters. Don't provide any and just click OK.

second screen

If everything is fine, you will see the Terminal Window with the proper output.

third screen

There is nothing wrong with the code, I suggest you focus on the BlueJ documentation.