Results 1 to 4 of 4

Thread: How to package in java

  1. #1
    Join Date
    Mar 2009
    Location
    Ghana
    Posts
    15

    How to package in java

    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?

  2. #2
    Join Date
    Mar 2008
    Posts
    258

    Re: How to package in java

    Follow the steps to achieve the packages in JAVA Netbeans.
    1. Click New Project in File menu or Welcome window.
    2. Choose Category General, and Project Java Application (probably the defaults). Click Next.
    3. The New Java Application dialog box will open fill the following details into it.
    4. 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".

  3. #3
    Join Date
    Aug 2007
    Posts
    1,098

    Re: How to package in java

    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.*;

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: How to package in java

    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.

Similar Threads

  1. Package format in Eee Note Package Manager
    By Sanju!Ekta in forum Portable Devices
    Replies: 6
    Last Post: 11-08-2011, 11:30 PM
  2. Replies: 5
    Last Post: 18-06-2011, 09:33 PM
  3. Java - scanner package for user input
    By Shaan12 in forum Software Development
    Replies: 4
    Last Post: 21-07-2010, 02:49 PM
  4. JAVA Fundamental: The java.io package
    By TechyGuy in forum Guides & Tutorials
    Replies: 4
    Last Post: 05-02-2010, 02:14 PM
  5. Where to get this package ????
    By kashiqirphan in forum Software Development
    Replies: 1
    Last Post: 19-02-2009, 12:39 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,756,801.91961 seconds with 16 queries