Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2011
    Posts
    93
    Rep Power
    0

    Default New to NetBeans - project with multiple classes

    Hello. I'm new to NetBeans and pretty new to Java as well. I apologize in advance for any excessively stupid questions.

    I created a new NetBeans project (called UsesMosaic) in it's own package. The UsesMosaic calls on methods in a class called Mosiac. I have the Mosaic.class already writen and compiled, and it resides in the same folder in which I have the UsesMosaic package. Anywhere in the UsesMosaic program that calls a method in the Mosaic.class, I get an error from NetBeans: "Cannot find symbol symbol: variable Mosaic".

    Can anyone tell me how to set up NetBeans so a project can access methods from another file?

    I can write the same UsesMosaic program in WordPad, save it in the folder where I have the Mosaic.class, and successfully compile and run it using a command prompt. This tells me that my coding is correct, and that UsesMosaic can correctly access the Mosaic.class. Now how do I do this when writing UsesMosaic in NetBeans?

    Thanks.

  2. #2
    pbrockway2 is online now Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,574
    Rep Power
    12

    Default Re: New to NetBeans - project with multiple classes

    I created a new NetBeans project (called UsesMosaic) in it's own package. ... I have the Mosaic.class already writen and compiled, and it resides in the same folder in which I have the UsesMosaic package. ... I can write the same UsesMosaic program in WordPad, save it in the folder where I have the Mosaic.class, and successfully compile and run it using a command prompt.
    This suggests a problem to me. Do UsesMosaic and Mosaic belong to the same package - ie do they both have "package <whatever>;" as the first line of their source code? If so then the class files should go in the same folder, if not then they should not.

    As a general rule if one of your classes belongs to a specific package, then they all should.

  3. #3
    Join Date
    Mar 2011
    Posts
    93
    Rep Power
    0

    Default Re: New to NetBeans - project with multiple classes

    Hello. Thanks for your reply

    The Mosaic.class is not part of or in any package.

    When I created the new NB project (UsesMosaic), the wizard gives an option to place the new project in a package. I used this option to create a new package for the UsesMosaic project. That package exists in its own folder that resides in the same folder that contains the Mosaic.class file.

    If I understand packages correctly, the Mosaic.class and the UsesMosaic.class should reside in the same package. But I do not know how to do this in NetBeans.

    Let's try ths question. I have a file named Mosaic already written and compiled. I want to write a new program in NB that will call on the Mosaic.class. How do I do this in NB?

    Quote Originally Posted by pbrockway2 View Post
    This suggests a problem to me. Do UsesMosaic and Mosaic belong to the same package - ie do they both have "package <whatever>;" as the first line of their source code? If so then the class files should go in the same folder, if not then they should not.

    As a general rule if one of your classes belongs to a specific package, then they all should.

Similar Threads

  1. Help with multiple classes
    By Aimforthehead in forum New To Java
    Replies: 28
    Last Post: 11-28-2011, 12:01 AM
  2. Replies: 1
    Last Post: 09-09-2011, 07:57 PM
  3. Java project with multiple classes
    By trakke in forum New To Java
    Replies: 1
    Last Post: 04-28-2011, 09:16 PM
  4. Multiple classes
    By Lund01 in forum New To Java
    Replies: 1
    Last Post: 03-16-2011, 03:58 PM
  5. help with GUI and multiple classes
    By sssss in forum Advanced Java
    Replies: 14
    Last Post: 01-16-2011, 11:08 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
  •