aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Is it netbeans or is it me? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Is it netbeans or is it me?" Watch "Is it netbeans or is it me?" New topic
Author

Is it netbeans or is it me?

Stephen Fairchild
Greenhorn

Joined: Oct 23, 2010
Posts: 2
Hi I am both new here and to Java. I took a class last semester but he never taught us the import things

First off I know how to create a class and how to create objects

My problem is.. I don't know how to create objects of classes that are not in the same .java file

I know by looking through my folders that netbeans compiles the .java file for you so im wondering if that has something to do with it

Whenever I make a .java file with multiple classes I have no trouble creating objects, but if i have 2 .java files with different classes I can't call one class from the other .java file..

Is this because it won't work like this in netbeans or am I just not understanding this right?

Maybe I shouldn't use netbeans? and maybe eclipse???
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
It's not NetBeans. You need to learn the "import things". If you post your code along with the errors you're getting, someone can probably help.
Stephen Fairchild
Greenhorn

Joined: Oct 23, 2010
Posts: 2
Well thank you!

In my persuit of making an example and getting errors I got it to work.

I found out that netbeans was creating the new .java file in the wrong spot.

I now have both .java files in src>project>
and both .class files are in build>classes>project

Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

Next you might want to learn about packaging in Java, and Welcome to Javaranch


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 561
You may find this article useful:

Access to Members of a Class

You'll note the mention of "package-private" in that discussion, which is what Vijitha may be referring to in his/her response (sorry, I'm not certain of the gender of that name). Said another way, you can specify that multiple classes are members of the same package name by adding the statement:



on the first line of code in each class file that you want to be a member of the same package. This 'packaging' increases the visibility of one class to all others in the same package.

You can learn more about the Java package concept, naming conventions, etc., later in the link I included above.


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

Greg Brannon wrote:... (sorry, I'm not certain of the gender of that name)...

You will find so many of those here in the forums
And welcome to JavaRanch, Greg
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Is it netbeans or is it me?