Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Hello World program not generating output with NetBeans and Mac

  1. #1
    Junior Member
    Join Date
    Sep 2017
    Location
    Campbell, CA
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Hello World program not generating output with NetBeans and Mac

    Hi,

    I am a rank beginner with Java. I have purchased "Java for Dummies" by Doug Lowe, and the first program is Hello World.

    THIS CODE DOESN'T APPEAR TO DISPLAY OUTPUT

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

    THIS CODE DISPLAYS OUTPUT

    public class CosineClass {
    public static void main(String[] args) throws Exception {
    double angle = Math.toRadians(90);
    Cos cos = new Cos();
    double cosine = cos.value(angle);
    System.out.println("Cosine of angle "+angle+" is " + cosine);
    }
    }

    I have NetBeans up and running, and it runs simple math calculations. The System.out line works with the math computation. But, for some reason, it won't print Hello World. Has anyone run into this?

  2. #2
    Junior Member
    Join Date
    Sep 2017
    Location
    Campbell, CA
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Hello World program not generating output with NetBeans and Mac

    When I named the class and method both HelloApp, it worked.

    public class HelloApp {
    /**
    * @param args the command line arguments
    */
    public static void HelloApp(String[] args)
    {
    System.out.println("Hello, World!");
    }
    }

    --- Update ---

    Create a new project. Select Categories = Java and Projects = Java Application.

    Project Name = Dummies
    Enable the "Create Main Class" checkbox. Accept the default 2-part name convention. The first instance of "dummies" is the package name. Change the second instance to "MainClass". Click the [Finish] button. Now, create a new class at the package level named "HelloApp". The program will look as follows:

    /*
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    */
    package dummies;

    /**
    *
    * @author dianamecum
    */
    public class HelloApp {

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

Similar Threads

  1. Replies: 5
    Last Post: September 7th, 2014, 08:25 AM
  2. generating reports in netbeans
    By newtolearningjava in forum Java IDEs
    Replies: 2
    Last Post: April 24th, 2014, 10:29 AM
  3. generating reports in netbeans
    By newtolearningjava in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 24th, 2014, 10:29 AM
  4. Replies: 1
    Last Post: June 21st, 2013, 02:23 PM
  5. Password Generating Program Help
    By iAce in forum Java Theory & Questions
    Replies: 7
    Last Post: December 22nd, 2012, 09:00 PM

Tags for this Thread