For my degree project I am trying to write a simple messaging system for the shift I supervise at work to communicate outside of work across the internet. It will display a shift rota for the day and also they can send messages to each other, asynchronously. However i am failing miserably to code it. It is suppose to work on RMI
The message system has three classes, message, messageOperator, messageOperatorHolder and an interface MessageOperatorInterface This is the code for message
An this is the code for messageOperator
And then this is the messageOperatorHolder
When I compile it I get cannot use non-static method to reference static context.
I know this means that I am referencing the class messageOperator rather than an instance. But I need a system that will allow me to create messageOperators.
A little help? will need help the server in future if any one has got the time?
Originally posted by Al Dodd: When I compile it I get cannot use non-static method to reference static context.
More of a beginner's question if you are getting THAT error message.
Why are you using HashTable and Enumeration rather than more modern classes? Why have you got a void getMessages() method? Why are you not calling your classes by the correct names starting with a Capital Letter? Then you would realise that you are calling instance methods on the name of their type (the class name) rather than on the name of an object.
Just to reinforce what Campbell Ritchie said, check out number 10 of Top Ten Errors Java Programmers Make Just ignore number 6 as it's completely wrong (the author of the faq never read Pass-by-Value Please [ June 03, 2008: Message edited by: Eric Weinberg ]
Joined: Feb 08, 2008
Okay I take on board the comment on coding convention and will change it and I am sorry for posting in the wrong forum!
What modern class would you suggest I use?
I already new why I was getting the non-static error but thanks for pointing out the FAQs, One of them answered another question I had. Regards Al
Joined: Oct 13, 2005
Modern classes? HashMap and Iterator. And declare your Map like this:-