www.webdeveloper.com
Results 1 to 4 of 4

Thread: Creating java package

  1. #1
    Join Date
    May 2005
    Posts
    9

    Creating java package

    Can you please tell me how to create java packages, where to store the package and how to access them later.

    Thanks in advance.

  2. #2
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    To create a package, you simply need to use the package keyword at the top of the file:
    Code:
    package yourPackageName;
    When compiled, a directory will be created (using the package name) to store the files using that package.

    To access that package later, you need to use the import statement.
    Code:
    import yourPackageName.*;
    That will referance all class files within that package. You can import on one class by using:
    Code:
    import yourPackageName.ClassName;
    Regards.

  3. #3
    Join Date
    May 2005
    Posts
    9

    reply

    thats how i have done it. but when importing the package in a new program i am getting the following msg:
    package packname does not exist.
    can you tell me where i should store the package

  4. #4
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    In the classpath. Your package (directory of class files) should be placed in the directory that is specified as your classpath -- the folder that contains you compiled .class files.

    Regards.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles