Join 149,823 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,671 people online right now. Registration is fast and FREE... Join Now!
Since im completely new to java, the explanations given didnt make very much sense...im still not sure what I'm supposed to do inorder to make my program work..is there a specific function that needs to be written?
I don't think that it is supposed to be a compilation error. Eclipse likes to complain about some idiot things, that you should simply ignore (it is one of those, it is most likely a warning, or problem, or whatever the heck it calls 'em). So if your program doesn't stat, try to look at the compilation errors (Console tab/view). What you quoted here, is most likely from the problems view, and should be ignored.
What you are receiving is a warning, not an error, so it won't stop your program from compiling and running, if you're using Eclipse. If you're compiling from the command line you'll have to use "javac -Xlint yourClass.java." Since you're just now learning Java, I wouldn't worry too much about this. Just remember that, down the road, you will want to include this SerialVersionID. If you want to include it now (and you're using Eclipse), click on the little yellow warning icon on the left margin and it will give you some options to automagically generate it in for you.
Just remember that, down the road, you will want to include this SerialVersionID.
Why? It is computed automatically. There is an urban legend surfacing from time to time, that declaring it makes serialization faster, because the JVM has to recalculate this value a lot of times. It is only half true: the JVM calculates it, but only once (either when the class is loaded, or when it is first needed, I am not sure). So generally, you can forget about it, unless you want to override serialization in a way, so that it lets you import a class into a different version from the one it was serlialized as (can be quite risky!).
Just remember that, down the road, you will want to include this SerialVersionID.
Why? It is computed automatically. There is an urban legend surfacing from time to time, that declaring it makes serialization faster, because the JVM has to recalculate this value a lot of times. It is only half true: the JVM calculates it, but only once (either when the class is loaded, or when it is first needed, I am not sure). So generally, you can forget about it, unless you want to override serialization in a way, so that it lets you import a class into a different version from the one it was serlialized as (can be quite risky!).
Why not? If you're nimble with the mouse it only takes a few seconds to generate one, so - I say again - why not just be in compliance? But it does actually have a purpose, unrelated to any speed enhancements.
QUOTE
In anticipating the need to evolve a serializable class, Java serialization provides a serialVersionUID, also called suid, in the ObjectStreamClass for version control. suid is used to inform the Java serialization mechanism which version of the class is compatible with this serialized object. However, the importance of this field is often overlooked, resulting in release incompatibility...
Okay so I clicked the console tab and this is the error that it gives
java.lang.NoClassDefFoundError: message Exception in thread "main"
it cannot find class message check you have the name correct - in particular capital letters etc - java is case sensitive, e.g. message is not the same as Message, etc
Are you using Eclipse? If so, you should see little red icons that will lead you to the problem. Or look in the "Problems" tab and when you see a red icon, double-click it and it will take you to the problem.