Answer to Monday’s Question
This week’s question centered around this code:
// A jolly message is written to the screen!that had been saved in a file called JollyMessage.java.
class Jollymessage
{
public static void main(String[] args) {
//Write the message to the terminal window
System.out.println("Ho Ho Ho!");
}
}
As I see from Monday's comments, the eagle-eyed of you quickly noticed that the class is called “Jollymessage” whereas the filename is “JollyMessage.java”.
For those that didn't see the error, remember that Java is case sensitive. The compiler won’t complain because technically there is nothing wrong with the code. It will create a class file that matches the class name exactly i.e. Jollymessage.class. So, when you come to run the program called JollyMessage, you can't because there is no file called JollyMessage.class.
The error you get when you try and run a program with the wrong name is:
Exception in thread “main” java.lang.NoClassDefFoundError: JollyMessage (wrong name: JollyMessage)..
Happily it’s a simple fix, just change the class name so that it matches the file name (or vice versa).


Students make this sort of mistake all the time. It is particularly likely if they are learning Java as a second language. The habits gained while using another language often interfere with the early lessons in Java. Good job for highlighting this important detail. A lot of beginners can avoid the usual head scratching that results from not knowing this beforehand.
Hi Louie: Your correct, if a student coded in VB for example thats not case sensitive then they will make this sort of mistakes alot. Those that use C-style languages (Java, C#, C, C++) are all case sensitive.