So i had this .java file named as 'anagram.java'. After compiling with javac the resultant .class file i get is named 'Anagram.class' (with a capital A) This may seem inconsequential but so far, I've managed to get the same name in both the code and compiled file. Would anyone know why this happened? You can see a picture of the commandline here
1 Answers
2
votes
Note that javac is case-insensitive for Windows, but not for Linux, for example. Your class name in the anagram.java file is capitalized, i.e. it is class Anagram (as it should be), so javac is using this capitalized version to make your class file. In general, keep java filenames capitalized as well since it is convention, and depending on the operating system, javac may not work with discrepancies in capitalization.
anagram.java
? I'll bet it'sAnagram
(and notanagram
). Thus the name of the.class
file isAngram.class
, notanagram.class
, in spite of the source file beinganagram.java
rather thanAnagram.java
. In other words, the name of the.class
file comes from the name of the class, not the name of the Java source file. - Kevin Andersonclass Anagram
, it'll be Anagram.class - vicki