Forum : java package
Brief description  about Online courses   join in Online courses
View Sangita  Biswal 's Profile

java package

package family;

public class Mother
{
public static void display()
{
System.out.println("My mother's name is Kanaka Lata Biswal");
}
}

import MyClass.family.*;

public class MyFamily{

public static void main(String args[])
{
Mother.display();
}
}


MyFamily.java:7: cannot access MyClass.family.Mother
bad class file: .\MyClass\family\Mother.class
class file contains wrong class: family.Mother
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
Mother.display();
^
1 error

please help me in importing the package in the right way.
Asked by Sangita Biswal | May 12, 2010 |  Reply now
Replies (5)
View priti m naik 's Profile
thx
Oct 5, 2010
View suman dustakar 's Profile
ya it is possible, u hav to first create the package called MyClass, & inside tis package u hav to create another package called Family, tis can be done by declaring as,,,, package MyClass; package Family;.. after tis, u can create MyFamily.java class.. gud luck...
May 14, 2010
View nishant gaurav 's Profile
write the package class program in seprate notepad page and save it
as .java file. then put it inside a folder named as the package name,then put the main class in seperate notepad and after saving it put this file and the package folder in a seperate folder thenset path to this folder, it will run surely.
May 14, 2010
View sangita biswal 's Profile
Hey thanks.But i want to save MyFamily.java inside the default package in which package i have MyClass package and family package is inside this MyClass package.Is this possible?
May 13, 2010
View siji jimmy 's Profile
import family.*; is enought since u create ur Mother class on family package and import only that one.
May 12, 2010