I have created a directory in my C drive with the name food.
In this directory I have made a class called Fruit.java such as
package food;
public abstract class
Fruit {
public abstract void methodFruit();
}
I compiled it using
c:\food>javac Fruit.java
Then i made a class in C drive with default package such as
import food.Fruit;
class Apple extends Fruit
{
public static void main(
String[] args)
{
System.out.println("Apple");
}
public void methodFruit()
{
System.out.println("Fruit");
}
}
When i try to compile this file using
c:\>javac Apple.java
I get the following error
Apple.java:1: package food does not exist
import food.Fruit;
^
Apple.java:2: cannot access Fruit
bad class file: c:\food\Fruit.class
class file contains wrong class: food.Fruit
Please remove or make sure it appears in the correct subdirectory of the classpath.
class Apple extends Fruit
^
I have set the classpath as
set classpath=c:\food;
How should I correct this problem.