I am in Windows OS, working in eclipse IDE, I have following two scenario:
1. I have created below class, this is in Employee.java class (E is in uppercase):
public class Employee {
public static void main(String[] args) {
employee emp = new employee();
emp.test();
}
}
//here e is in lowercase
class employee {
public void test() {
System.out.println("I am in test()");
}
}
In this case I got below Exception:
Exception in thread "main" java.lang.NoClassDefFoundError: employee (wrong name: Employee)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
.
.
.
at Employee.main(Employee.java:4) // i.e at emp.test();
2. I have created below class, this is Employee.java class:
public class Employee {
public static void main(String[] args) {
}
}
Now when I tried to create employee.java (e is in lower case) class in same package, I got the message in eclipse that Type with same name but different case exists.
My question is: Java is case sensitive. Does this means JVM (windows and UNIX based) is case sensitive or the compiler is case sensitive? And why it gives that exception in scenario 1 and eclipse does not allow me to create employee.java file in same location in scenario 2.
Also remember I am on Windows OS which is case insensitive for file name, so I know that it will not allow employee.java and Employee.java in same location. Does this violate in any means Java case sensitivity?