posted 15 years ago
Hi
One point actually striked me about this .....
When we use javac command , we are actually trying to run a java file , not java class itself.
So , let us say that my above mentioned code was saved in "HelloWorld.java" file.
Now , we can use below mentioned javac command to compile this class for eg
a. javac HelloWorld.java
b. javac Helloworld.java
c. javac helloworld.java
all above three command will be success and class will get compile .
REASON was Windows environment is by default case insensitive. So , when we run any of the above mentioned javac command , actually , javac command search for file mentioned as an argument and Window's case insensitive feature make javac command to successfully find this file (even if file name case is different ).
But , when we are running the compiled class with java command , here , JVM actually search for a class whose name is mentioned in argument of java command
for eg
java Helloworld
here , JVM search for "Helloworld" class but since JAVA language is case sensitive , so , JVM is not able to find a class whose name is 'Helloworld'.
so , we have to give exactly same name of class as an argument to java command.
More over, I think , since UNIX environment is CASE - SENSITIVE , so if we try to compile same file on UNIX environment where JAVA is installed , there , javac command such as
javac Helloworld.java
or
javac helloworld.java
will not work.
Thanks
Abhay Agarwal
Oracle certified JPA Developer (1Z0-898),Oracle certified Java 8 Programmer I (1Z0-808), Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I, CIW Certified Ecommerce specialist