Results 1 to 2 of 2
  1. #1
    elizabeth is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default netBeans problem Restated

    netBeans doesn't Execute the second code Why?
    this works
    Java Code:
    
    package HelloWorldApp_pkg;
    
    public class HelloWorldApp {
    
    public HelloWorldApp() {
    }
    
    public static void main(String[] args) {
    System.out.println("Howdy");
    }
    }
    it doesn't work
    Java Code:
    package Project_1_Pkg;
    
    public class HelloWorldApp {
    public static void main(String[] args) {
    System.out.println("Howdy");
    }
    }
    problem
    Java Code:
    "class HelloWorldApp is public, should be declared in a file named HelloWorldApp. java"
    Can anyone explain to me why?

  2. #2
    Join Date
    Aug 2007
    Posts
    25
    Rep Power
    0

    Default

    There doesn't seem to be a problem with the actual code. Do you have two different HelloWorldApp classes in separate package namespaces? Or do you only have one HelloWorldApp class in the HelloWorldApp_pkg namespace?

    Creating two different packages with classes of the same name isn't a problem, but creating a package with a class of one name and declaring that class as belonging to a different namespace will cause problems.

    Also, you may want to use standard Java naming conventions for packages. For example, package names should be lowercase, and begin with the top-level domain of your organization (e.g. org.yourapp.yourpackage.yoursubpackage)

    Good luck,

    Joe

Similar Threads

  1. help with netBeans
    By the godfather01 in forum NetBeans
    Replies: 11
    Last Post: 02-01-2009, 05:48 PM
  2. Problem with wsimport / Netbeans
    By buk110 in forum Advanced Java
    Replies: 0
    Last Post: 03-17-2008, 08:47 PM
  3. NetBeans 5.5.1 Help.
    By padutch2 in forum New To Java
    Replies: 6
    Last Post: 12-03-2007, 04:01 AM
  4. Problem with display in Netbeans 5.5
    By Albert in forum NetBeans
    Replies: 1
    Last Post: 07-13-2007, 04:33 PM
  5. netbeans 64 bit
    By caspermel in forum NetBeans
    Replies: 1
    Last Post: 06-26-2007, 11:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •