Results 1 to 3 of 3
- 11-07-2012, 10:55 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 88
- Rep Power
- 0
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.
- 11-07-2012, 11:28 PM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Re: New to NetBeans - project with multiple classes
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.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.
As a general rule if one of your classes belongs to a specific package, then they all should.
- 11-08-2012, 12:43 AM #3
Member
- Join Date
- Mar 2011
- Posts
- 88
- Rep Power
- 0
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?
Similar Threads
-
Help with multiple classes
By Aimforthehead in forum New To JavaReplies: 28Last Post: 11-27-2011, 11:01 PM -
accessing default generated private methods in Netbeans (in case of multiple classes
By lemontree45 in forum NetBeansReplies: 1Last Post: 09-09-2011, 06:57 PM -
Java project with multiple classes
By trakke in forum New To JavaReplies: 1Last Post: 04-28-2011, 08:16 PM -
Multiple classes
By Lund01 in forum New To JavaReplies: 1Last Post: 03-16-2011, 02:58 PM -
help with GUI and multiple classes
By sssss in forum Advanced JavaReplies: 14Last Post: 01-16-2011, 10:08 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks