Reputation: 884
When I was executing a Java program I noticed that the Java compiler is case-insensitive with respect to file names whereas the Java interpreter is case-sensitive.
The Java interpreter being case-sensitive is very much understandable as, the name of the class file is the name of the class defined in the Java code.
Is there any good reason for the Java compiler being case-insensitive?
Upvotes: 2
Views: 1647
Reputation: 16359
Presumably you're running the compiler on Windows or another operating system with either a case-preserving or case-insensitive filesystem. If you ran it on an OS that used a case-sensitive filesystem, you would get different results. In other words, it's not the compiler, it's the operating system (or rather, its filesystem).
Upvotes: 3
Reputation: 36339
Windows is still an OS for children and people that just want to surf the Web or do their fiscal paperwork. But not for developers.
Since almost 20 years, MS has done almost nothing with respect to:
Hence, if you develop Java, make sure you don't have class or package names that differ in case only. This will invariably lead to disaster.
Do yourself a favor, make a bit room on your HD, or attach an external one, and install a dual boot LINUX. If must be, make a virtual machine. You'll never look back, once you got your favored IDE installed. And you'll learn a bit or two along the way.
Upvotes: 3
Reputation: 2122
it depends on the underlying file system. Windows' file system is not case sensitive, so the when the java compiler looks for 'Foo.java', the OS will happily open 'foo.java' instead.
Upvotes: 3
Reputation: 887449
The Windows filesystem is case-insensitive.
You cannot (sanely) find a case-sensitive file on a case-insensitive filesystem.
If you run javac
on Linux with a case-sensitive filesystem, it will be case-sensitive.
Upvotes: 7