|
|
Re: Package not found eror
|
Posted: Feb 16, 2009 1:53 AM
|
|
> Created class Print in MyEckel\Avis\MyLove: > > package avis.mylove; > import java.io.* ; > > public class Print > { > // Print with a new line > public static void print(Object obj) > { > System.out.println(obj) ; > } > > // Print a new line by itself > public static void print() > { > System.out.println() ; > } > > > Then: > Created class Apply in Eckel > > import static avis.mylove.Print.*; > public class Apply { > public static void process(Processor p, Object s) { > print("Using Processor " + p.name()); > print(p.process(s)); > } > } > > added c:\MyEckel to the CLASSPATH variable > > When I try to compile class Apply, I got a message saying > package avis.mylove is not found > > What is the problem? (Both Print and Apply are fragments > of the original classes - used for demonstration)
1) Your class Apply should be in your MyEckel folder as Apply.java
2) Your import statement should read:
import avis.mylove.Print; // This means import the class Print from avis.mylove
or
import avis.mylove.*; // this means import everything in package avis.mylove - which includes the class Print
and not: "import static avis.mylove.Print.*;"
|
|