954,152 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

'[Class] is not abstract..' error when i use 'implements'

G'day..

Am new to this whole object oriented stuff. But keen to learn. Am trying to compile this class but keep getting the following error when i declare anything that 'implements'. i remove the declarations and all subsequent code references and she compiles.. any ideas??

*********************START_OF_ERROR**********************
ChatClientApplication.java:6: ChatClientApplication is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener public class ChatClientApplication extends Frame implements ActionListener, Item
Listener, WindowListener
^
1 error
***********************END_OF_ERROR**********************
Cheers..
:eek:

javaLearner
Newbie Poster
5 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
 

To implement an interface (in this case ActionListener or ItemListener), you must write all the functions that the interface provides. One such function you're missing is actionPerformed(ActionEvent). If you put this function into your ChatClientApplication class, it will stop complaining.

Put this in your class:

public void actionPerformed(java.awt.event.ActionEvent e)
 {
 }


Hope this helps!


Ed
*********************START_OF_ERROR**********************
ChatClientApplication.java:6: ChatClientApplication is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener public class ChatClientApplication extends Frame implements ActionListener, Item
Listener, WindowListener
^
1 error
***********************END_OF_ERROR**********************
Cheers..
:eek:

cosi
Junior Poster
153 posts since Aug 2004
Reputation Points: 17
Solved Threads: 1
 

Hi Ed,

that's brilliant! Thankyou, code compiles now..

-> ha! So now of course I attempt to run it and get:
----------------------------------------------------------------------
C:\Java Chat Application WIP\My Source>java ChatClientApplication.class
Exception in thread "main" java.lang.NoClassDefFoundError: ChatClientApplication
/class

----------------------------------------------------------------------
I am not 'constructing' correctly??, i.e.

public class ChatClientApplication extends Frame implements ActionListener, ItemListener, WindowListener

and then:

//Class constructor method..
public ChatClientApplication()
{
// initialise the user interface
init();
}

and then:

//Main method to bring everything together..
public static void main(String args[])
{
new ChatClientApplication();
}

...if anyone is bored and wants to help!
:eek:

javaLearner
Newbie Poster
5 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
 

Don't have the .class at the end.

Just run the line
java ChatClientApplication

Hope this helps. ;-)


Ed

Hi Ed,

that's brilliant! Thankyou, code compiles now..

-> ha! So now of course I attempt to run it and get: ---------------------------------------------------------------------- C:\Java Chat Application WIP\My Source>java ChatClientApplication.class Exception in thread "main" java.lang.NoClassDefFoundError: ChatClientApplication /class ----------------------------------------------------------------------

cosi
Junior Poster
153 posts since Aug 2004
Reputation Points: 17
Solved Threads: 1
 

Good point, thankyou Ed.

Turns out I did not have my CLASSPATH environment variable set correctly (set CLASSPATH=), so class files could not be found and nothing was able to run..

Thanks for help anyway..

:-|

javaLearner
Newbie Poster
5 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You