manikandan jayakumar wrote:
usually we will import the package
we import classes not packages
manikandan jayakumar wrote:
but in my case how to import?
1.first the method should be public(assume the is no IS-A relationship)
2.import the class which contains the method
3.create an instance of that class and call the method(if the method static then call it using Class name, object creation is not required)
hmm, but remeber I always use *javac package\classname.java* and java package.classname . so, I suggest you to use as in
C:\Java>javac pack\hai.java insteadof C:\Java\pack>javac hai.java
set classpath=%classpath%;.;<path of your package>
you need to specify the path where your package
example
if package exist in d:\javaprg\pack\Sample.class
where pack is package which has sample.class
set classpath=%classpath%;.;d:\javaprg;
you need to specify the path where your package
or you can also specify the package path in the environment variable classpath
right click mycomputer- properties-advance-environment variable
under the heading system variable create environment variable classpath
name - classpath
value- %classpath%;.;d:\javaprg;