Madurai,
I guess Maha can answer on behalf of Tony.
What you say is correct. It runs from any directory. The discussion of 'Making the main(String[] args) method to be package/protected/private level and still it runs' is brought up already here. The newer versions of JDK does in fact allows this. Someone posted that earlier version of JDK didn't. I am using jdk1.2.2 and it runs from any directory. I also think that we should go according to JLS. What if our present code is run in future using different implementation which does in fact goes as per JLS?
The JLS says this . The entry point of any application which is the main method has to be
public static void main(String[] someName) { }. What tony told was as per the JLS spec.
Other than this Java behaves as told in JLS. The compiler checks All access levels (public/protected/package/private..) at the compile time itself whether the accessed member of the other class is in fact really obeys the rules defined for access levels. I tried to give you an example. Compile this. You will get compile time error. It would't even pass the compile check.
Compile like this. Your current dir has to be in classPath.
javac -d . Point.java
javac -d . PlusPoint.java regds
maha anna
<pre>
//Point.java
package points;
public class Point {
public static void public_static_printMe() {
System.out.println("I am from points.Point.public_static_printMe()");
}
protected static void protected_static_printMe() {
System.out.println("I am from points.Point.protected_static_printMe()");
}
static void package_static_printMe() {
System.out.println("I am from points.Point.package_static_printMe()");
}
private static void private_static_printMe() {
System.out.println("I am from points.Point.private_static_printMe()");
}
}
//PlusPoint.java
package morepoints;
import points.Point;
public class PlusPoint {
public static void main(String[] args) {
Point.public_static_printMe();
Point.protected_static_printMe();
Point.package_static_printMe();
Point.private_static_printMe();
}
}
</pre>
[This message has been edited by maha anna (edited April 18, 2000).]