Here is the dir structure c:\java\suncert\OverLoadEx\OverLoadEx.java When I try to compile it in the dir c:\java\suncert\OverLoadEx java OverLoadEx.java I get an error OverLoadEx.java:1: OverLoadEx clashes with package of same name Here is the file : class OverLoadEx { public static void main(String args[]) { int x; long y; } }
Hi Christian I was facing similar problems Thing to remember is that packages memic directory structures and when you run this file you should use the fully qualified name in your case : at this dir : E:\com\christian\examples\ run this command : java com.christian.examples.Example1 This should work satish
my java file is called p1.java directory C:\java \p1.java classpath is set till C:\java Source file p1.java is as follows : package pack; class p1 { public static void main(String args[]) { System.out.println("Hello world"); } } At C:\java I compile it using javac p1.java Output C:\java\p1.class when i run it : java p1 I get an error Error :"NoclassdefFoundError wrong name pack/p1" So I tried java pack.p1 Error :"NoclassdefFoundError" So now i compiled my file again like this javac -d . p1.java This created a directory structure like this : C:\java\pack\p1.class Now I added to my classpath to look like this : c:\java;c:\java\pack I tried to run it at C:\java\pack java p1 Error = :"NoclassdefFoundError" It succeeded at c:\java\pack and also at c:\java when i used the following command : java pack.p1 BUT I DONT KNOW WHY IT WORKED !! ie can anyone please explain what is happening ? I am lost !! thanks satish