I will like to package my project that i have finish in jave netbeans 6.5. Please can anybody help me with any third-party software or how i can do that?
I will like to package my project that i have finish in jave netbeans 6.5. Please can anybody help me with any third-party software or how i can do that?
Follow the steps to achieve the packages in JAVA Netbeans.
- Click New Project in File menu or Welcome window.
- Choose Category General, and Project Java Application (probably the defaults). Click Next.
- The New Java Application dialog box will open fill the following details into it.
- Project Name
- Choose a Project Location
- Set as Main Project
- Create Main Class
- Package name and main class name
The package name is the part before the dot. It will probably already have been set from the Project Name field, but you don't really have to use this default package name. You can change it to any legal package name, or even get rid of it entirely (and the dot) to make it a "default" package. I often use "com.fredswartz.whatever" to put my "whatever" package in a package hierarchy that uniquely identifies it as mine. Package names should be in lower case.
Anonymous / default package. You technically don't have to use packages, but Sun strongly recommends that you do because it may make it easier to access resources after you've deployed your program.- Finish. All project files will be created when you click this. The main class of your project should now be showing in the editor window. It's ready to run and you can just click the green arrow to test it at this point. Of course it doesn't do anything yet, but you can at least verify that it compiles and "runs".
Well a package is really nothing more than compiling your source files in a directory (make sure you refer to it in your class path) . The name of the directory will be the name of your package. And of course at the top of each file you will declare it to be in that package like so:
package directoryname;
and then in your main classes you would import the package
import directoryname.*;
Suppose we have a file called HelloWorld.java, and we want to put this file in a package world. First thing we have to do is to specify the keyword package with the name of the package we want to use (world in our case) on top of our source file, before the code that defines the real classes in the package, as shown in our HelloWorld class below:
// only comment can be here
package world;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
One thing you must do after creating a package for the class is to create nested subdirectories to represent package hierachy of the class. In our case, we have the world package, which requires only one directory. So, we create a directory world and put our HelloWorld.java into it.
Bookmarks