tags:

views:

108

answers:

5

Using Netbeans, I want to put a package into another package. For example in Visual Studio 2008, I can have folder called "Nodes", and another folder inside of Nodes called "Expressions". How do I do this in Netbeans? I think a package in Java is equivalent to a folder in C#.

+3  A: 

You can create subpackages in java. If your package is called nodes, adding an expressions folder inside of it will create a nodes.expressions package.

FYI in Java, it is customary to use all lower case for package names.

Kevin
A: 

You can have any number of subpackages, e.g. abc.def.ghi.jkl.

fastcodejava
+2  A: 

For a package within a package, put the parent name, a period, and then the name of the child's package like so: Nodes.Expressions.

It will appear as it's own separate package in an IDE perhaps, but the folder hierarchy will be as you desire: Nodes/Expressions/[classes etc]

Kavon Farvardin
A: 

You can simply put the source in a folder within the current package structure. You reference it by adding a dot and the new package name to the end of the existing package name. In Netbeans, in the new file wizard, where the package name is referenced, you can input the new package by choosing an existing package and adding the .newpackagename to the end. Netbeans will then create the directory structure for you.

akf
+1  A: 

Kevin is correct in his answer about packages.

Heres Netbeans specific steps for adding a new package:

  1. In your Projects view, go to the parent package under "Source Packages".
  2. Right click on the Package and select New>Java Package (if Java Package doesn't appear in the list, select Other... and then pick Java>Java Package)
  3. Fill out the New Java Package wizard with name of the child package
Andrew Dyster