Hi there,

I've just switched to Eclipse. I've been using TextPad so Eclipse is pretty cool..
But I've been getting weird error messages that I don't understand/not used to.
Here they are:

JButton btnEnter = new JButton("Enter");
		btnEnter.addActionListener(this);

Here the Error says: Multiple markers at this line.
-Syntax on token "this", delete this token.
-Syntax error on token(s), misplaced construct(s).

What the hell?

And I also had to declare this (below) otherwise Eclipse got all cocky saying that I should.

static final long serialVersionUID;

What is this and why did I have to declare this?

Thanks for taking a look at this..

Is line 2 part of a method? (it should be)

the dreaded serialVersionUID is because the API says any Serializable class should declare a version number so that if serialization changes you will know which version was serialised when you try to de-serialise it. Eclipse is just picking up every low-level warning that a default stand-alone compile may suppress. Just let it put the version variable in and don't worry.

Just let it put the version variable in and don't worry.

Just remember, however, that if the interface of the class changes (i.e. new public/protected methods, etc) to change that number or you will have problems if the class is actually serialised as part of the app.

Is line 2 part of a method? (it should be)

Aww crap, no it's not. It's under class level. Such a dumb mistake. I should remember that one can only declare/initialize under class level. Not work with the methods.(correct me if I'm wrong)

Otherwise thank you both for your help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.