Results 1 to 5 of 5
  1. #1
    Tarasj is offline Member
    Join Date
    Mar 2012
    Posts
    14
    Rep Power
    0

    Default java package and import help

    package pack;
    class Zoo
    {
    public void displayMyName()
    {
    System.out.println("hi my name is Tara");
    }
    }

    so i have written a programme like this and
    compiled it as javac -d D:\practise\package\tara D:\Practise\Package\Zoo.java

    here i have written the source file in Package and stored the class file inside tara directory
    So now from where should i compile this code so that i can import this package

    import pack;
    class DemoImport
    {
    public static void main(String[] args)
    {
    Zoo a=new Zoo();
    a.displayMyName();
    }
    }


    so what is the mistake i have done please help

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: java package and import help

    Your package name has to reflect the file structure, and yours does not appear to do this.

  3. #3
    Tarasj is offline Member
    Join Date
    Mar 2012
    Posts
    14
    Rep Power
    0

    Default Re: java package and import help

    what is the mistake i have done please rectify it

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,008
    Rep Power
    20

    Default Re: java package and import help

    See my post in your other package thread, linking to the tutorial on packages.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,237
    Rep Power
    19

    Default Re: java package and import help

    Lets keep this discussion in one place. Closing this thread.

    db

    THREAD CLOSED
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Import and package
    By Pojahn_M in forum New To Java
    Replies: 32
    Last Post: 08-10-2011, 09:14 PM
  2. javac does not import package from jar in 1.6
    By tonydr in forum Advanced Java
    Replies: 0
    Last Post: 05-26-2010, 10:34 PM
  3. Import your own package
    By Umi in forum New To Java
    Replies: 4
    Last Post: 02-15-2010, 09:05 AM
  4. How to import a Java package?
    By tyang in forum New To Java
    Replies: 4
    Last Post: 02-06-2010, 09:14 PM
  5. How to import a package in Eclipse?
    By naipulb in forum New To Java
    Replies: 2
    Last Post: 06-09-2008, 11:04 AM

Tags for this Thread

Posting Permissions

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