f



Java compilation error message.

Attempting to write my first java program that accepts user input.
When I add the listner events to the code it will not compile.  Below
is the code along with the error message:


Code:

import javax.swing.*;
import java.awt.event.*;

public class LottoEvent implements ItemListener, ActionListener,
    Runnable {

}

Compilation Error message:

javac LottoEvent.Java: LottoEvent is not abstract and does not override
abstract method itemStateChanged(java.awt.event.ItemEvent) in
java.awt.event.ItemListener public class LottoEvent implements
ItemListener, ActionListener, Runnable

                                               ^

                                     1 error
Any ideas on how to fix it would be appreciated.

0
11/28/2005 9:23:51 PM
comp.lang.java.help 13340 articles. 0 followers. Post Follow

3 Replies
765 Views

Similar Articles

[PageSpeed] 47

In message <1133213031.701119.288850@g47g2000cwa.googlegroups.com>, 
ri.johnson@juno.com writes
>Attempting to write my first java program that accepts user input.
>When I add the listner events to the code it will not compile.  Below
>is the code along with the error message:
>
>
>Code:
>
>import javax.swing.*;
>import java.awt.event.*;
>
>public class LottoEvent implements ItemListener, ActionListener,
>    Runnable {
>
>}
>
>Compilation Error message:
>
>javac LottoEvent.Java: LottoEvent is not abstract and does not override
>abstract method itemStateChanged(java.awt.event.ItemEvent) in
>java.awt.event.ItemListener public class LottoEvent implements
>ItemListener, ActionListener, Runnable
>
>                                               ^
>
>                                     1 error
>Any ideas on how to fix it would be appreciated.
>

Try

import javax.swing.*;
import java.awt.event.*;

public class LottoEvent implements ItemListener, ActionListener, 
Runnable {

public void run() {}

public void actionPerformed (ActionEvent evt) {}

public void itemStateChanged(ItemEvent item) {}

}


That error is telling you that you are implementing an interface (or in 
this case interfaces). Interfaces enforce certain methods, so when you 
implement the interface you have to implement the methods of the 
interface. That is why you're getting the errors.

See:

http://java.sun.com/j2se/1.5.0/docs/api/java/awt/event/ItemListener.html

http://java.sun.com/j2se/1.5.0/docs/api/java/awt/event/ActionListener.htm
l

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runnable.html


BTW the code you posted does not give the error you claimed, it says 
this:


C:\JAVA\LottoEvent.java:4: LottoEvent should be declared abstract; it 
does not define run() in LottoEvent
public class LottoEvent implements ItemListener, ActionListener, 
Runnable {

I take it that was a typo or mistake ;)




-- 
Jeffrey Spoon

0
JeffreySpoon (125)
11/28/2005 10:02:20 PM
On 28 Nov 2005 13:23:51 -0800, ri.johnson@juno.com wrote, quoted or
indirectly quoted someone who said :

>
>javac LottoEvent.Java: LottoEvent is not abstract and does not override
>abstract method itemStateChanged(java.awt.event.ItemEvent) in
>java.awt.event.ItemListener public class LottoEvent implements
>ItemListener, ActionListener, Runnable

This message sounds misleading. I think what it means is you failed to
provide a suitable itemStateChanged method to implement ItemListener.
-- 
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
0
11/28/2005 10:35:51 PM
If you have a class which is implemented from an Interface. You have to
add all the implemented methods.


ri.johnson@juno.com wrote:
> Attempting to write my first java program that accepts user input.
> When I add the listner events to the code it will not compile.  Below
> is the code along with the error message:
>
>
> Code:
>
> import javax.swing.*;
> import java.awt.event.*;
>
> public class LottoEvent implements ItemListener, ActionListener,
>     Runnable {
>
> }
>
> Compilation Error message:
>
> javac LottoEvent.Java: LottoEvent is not abstract and does not override
> abstract method itemStateChanged(java.awt.event.ItemEvent) in
> java.awt.event.ItemListener public class LottoEvent implements
> ItemListener, ActionListener, Runnable
>
>                                                ^
>
>                                      1 error
> Any ideas on how to fix it would be appreciated.

0
scigam (1)
11/29/2005 5:08:47 AM
Reply:

Similar Artilces:

[compilation error] debugging this error message "Object() in java.lang.Object cannot be applied to"
Hi,I have a class called Device that instantiates another class DbMoneyin this manner:=== return new DbMoney( money, hardware.getName() );===1) Both are in the same package, i.e. my.IMoney & my.Device2) When I compile them, javac complains with the error:Object() in java.lang.Object cannot be applied to (my.IMoney,java.lang.String) return new DbMoney( money, hardware.getName() ) ^Q) My arguments to the DbMoney constructor match that of its declaredmethod parameters. So that can't be the problem. What am I doingwrong ?Gavin On Mar 28, 3:25 pm, "Gavin&...

Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object
I downloaded jdk-6u7-solaris-sparcv9.tar.Z and installed it by these commands: # zcat jdk-6u7-solaris-sparc.tar.Z | tar -xf - # pkgadd -d . SUNWj6rtx SUNWj6dvx SUNWj6dmx # /usr/jdk/instances/jdk1.6.0/bin/sparcv9/java -version Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object # ls /usr/jdk/instances/ jdk1.5.0 jdk1.6.0 # uname -a SunOS sun1 5.10 Generic sun4u sparc SUNW,Sun-Blade-2500 Please help to fix the error. Thanks. TsanChung wrote: > I downloaded jdk-6u7-solaris-sparcv9.tar.Z and installed it by these > commands: > # zcat jdk-6u7-solaris-sparc.tar.Z | tar -xf - > # pkgadd -d . SUNWj6rtx SUNWj6dvx SUNWj6dmx > > # /usr/jdk/instances/jdk1.6.0/bin/sparcv9/java -version > Error occurred during initialization of VM > java/lang/NoClassDefFoundError: java/lang/Object It's missing or can't find rt.jar, right? How does the Solaris version find it's runtime files? Can you show us where rt.jar is? On Aug 20, 6:24=A0pm, Mark Space <marksp...@sbc.global.net> wrote: > TsanChung wrote: > > I downloaded jdk-6u7-solaris-sparcv9.tar.Z and installed it by these > > commands: > > # zcat jdk-6u7-solaris-sparc.tar.Z | tar -xf - > > # pkgadd -d . SUNWj6rtx SUNWj6dvx SUNWj6dmx > > > # /usr/jdk/instances/jdk1.6.0/bin/sparcv9/java -version > > Error occurred during initialization of VM > > java/lang/NoClassDefFoundError: java/lang/Object > > It'...

Error occurred during intialization of VM java/lang/NoClassDefFoundError: java/lang/Object
Good day to all, I have installed the j2se/netbeans binary bundle on red hat 9. I can run everything perfectly as root but when I try to compile with any other user I get: Error occurred during intialization of VM java/lang/NoClassDefFoundError: java/lang/Object When I saw this it seemed like a permissions problem but I checked the permissions and everything seemed fine. All users have execute permissions of javac and java. I have read other threads dealing with the same or similar problem but have not reached any solution yet. I would appreciate if anyone that has run into this type o...

java.lang.IllegalStateException: No Java compiler available
tearing my hair out on this one.Thuis started as an upgrade issue till i realised that my un-usedtomcat5 installation didn't work either with my test jsp.I have, in desparation, un-installed all java / tomcat libs and re-installed only those required to get thetomcat6-6.0.14-1jpp.noarch.rpm (and the band-waggon) loadedfirst I installed java_app_platform_sdk-5_02-linux.binthis shows (after I set alternatives to point to the /opt/SDK/jdkdirecrtory)[root@squirrel ~]# javac -versionjavac 1.6.0java shows the same.I have set the following in profileCLASSPATH=$JDKHOME:$JDKHOME/lib/tools.jarJAVA_H...

Compiling Java from Java
I wish to write a Java program which can compile and run java source code. Can this be done without resorting to OS-specific calls to javac? I've seen suggestions that Ant might allow me to do this, but I've looking through the Ant manual, I can't see anything about it. Any hints? Malcolm Malcolm Ryan wrote: > I wish to write a Java program which can compile and run java source > code. Can this be done without resorting to OS-specific calls to javac? > I've seen suggestions that Ant might allow me to do this, but I've > looking through the Ant manual, I can&#...

Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object (ant/tomcat/spring)
Hi, I've been trying to get Spring working with ant and tomcat. Ant was building just fine, but I came in today and tried to build it and got this: Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object ?!?! Makes no sense to me. There _is_ an older version of java installed on my machine; but JAVA_HOME and ANT_HOME are set to the correct paths, and <which java>and <java -version> produce the correct version. Any help would greatly alleviate my frustration! Thanks in advance... Courtney ...

Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object (ant/tomcat/spring)
Hi, I've been trying to get Spring working with ant and tomcat. Ant was building just fine, but I came in today and tried to build it and got this: Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object ?!?! Makes no sense to me. There _is_ an older version of java installed on my machine; but JAVA_HOME and ANT_HOME are set to the correct paths, and <which java>and <java -version> produce the correct version. Any help would greatly alleviate my frustration! Thanks in advance... Courtney ...

help! compilation error in java
i am getting this error when i compile my java code Exception in thread "main" java.lang.NoClassDefFoundError: D:\STest\TestClient/java plzz tell me what to do.. i hv included all possible library files in the classpath..still the same error. plz tell me how resolve it.. Hi, kiran1785 schrieb: please use real name. > i am getting this error when i compile my java code which code ? Any samples ? > > Exception in thread "main" java.lang.NoClassDefFoundError: > D:\STest\TestClient/java How do you compile ? Do you use the right Filename - Classname ? >...

java error message java.io not found in import
Hi i'm trying to run a code like but i'm getting all the time the same error Class java.io not found in import import Java.io i guess the problem is that i dont have the header in the include folder,doenst anyone have solution for me? thread wrote: > Hi i'm trying to run a code like but i'm getting all the time the same > error > Class java.io not found in import > import Java.io 1. Capitalization matters. The package name is `java.io', not `Java.io' 2. The first-person subjective pronoun is `I', not `i'. 3. There is no class `java.io'; there is a package `java.io' which contains such useful classes as Reader or Writer... Perhaps you wanted to import all of java.io, in which case the syntax is `import java.io.*' -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth On May 15, 9:55=A0pm, thread <yaniv...@gmail.com> wrote: > ...i'm trying to run a code like but i'm getting all the time the same > error > Class java.io not found in import > import Java.io > > i guess the problem is that i dont have the header in the include > folder,doenst anyone have solution for me? Try starting here(1) and here(2) (1) <http://pscode.org/javafaq.html#exact> (2) <http://pscode.org/sscce.html> For example, this is an SSCCE.. <SSCCE> import java.io; class TestCompile { } </SSCCE> ...and here is the *exact* error message &l...

Java Java
Have my first Open Source Linux Java Project. Working on a second right now. Coming out with a distro called OPEN*WINDOWS. It will be at www.black-and-company.com tab wrote: > Have my first Open Source Linux Java Project. > Working on a second right now. > > Coming out with a distro called OPEN*WINDOWS. > > It will be at www.black-and-company.com > Wasn't that the whole point of Lindows? Oh, right, we didn't care for that either. tab wrote: > Have my first Open Source Linux Java Project. > Working on a second right now. > > Coming out with a ...

java.lang.ExceptionInInitializerError: java.lang.ArrayIndexOutOfBoundsException
Hi, I am new to DB2. I am getting this error while loading the DB2Driver. I don't have any idea about where i might have gone wrong. please help me. Below is the stack trace. Stack Trace: java.lang.ExceptionInInitializerError: java.lang.ArrayIndexOutOfBoundsException at COM.ibm.db2.jdbc.app.DB2Driver.SQLAllocEnv(Native Method) at COM.ibm.db2.jdbc.app.DB2Driver.<init>(DB2Driver.java:245) at COM.ibm.db2.jdbc.app.DB2Driver.<clinit>(DB2Driver.java:130) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:120) Thanks in advance, Ganesh Majji ganesh.m@gmail.com wrote: > I am new to DB2. I am getting this error while loading the DB2Driver. I > don't have any idea about where i might have gone wrong. please help > me. Unfortunately my crystal bowl stays dark because you didn't mentioned your operating system and which DB2 version you're using. For Windows, *nix and OS/2 please ensure that your application is using the db2java.zip from SQLLIB\java. Check if there are multiple db2jdbc.dll on your system, remove any extra db2jdbc.dll files on the system. Ensure that you can connect to DB2 with the DB2 workstation tools from your machine. sorry for not mentioning the system details. Operation System is SunOS (Solaris) and DB2 SDK 8.2.2 Thank you very much for the kind response, Ganesh Bernd Hohmann wrote: > ganesh.m@gmail...

Error when compile java code. package Java.awt does not exist
I am hoping to use java.awt.font.TextMeasurer to measure the width of a text string rendered in a proportional font. But java code that uses the java.awt.font class does not compile for me. Package does not exist. I have never compiled java code before. Is there a CLASSPATH or other environment variable that must be set to use Java.awt ? If not awt is there another graphics package I can use? here is my code. To compile I set the CLASSPATH = ".". Copy the code to an IFS stream file as ascii. Then run javac from QSH. import java.lang.*; ...

Java in Java
Is it possible to download a Java app (applet etc?) and run it inside a desktop Java app? -- Dirk http://www.transcendence.me.uk/ - Transcendence UK http://www.theconsensus.org/ - A UK political party http://www.onetribe.me.uk/wordpress/?cat=5 - Our podcasts on weird stuff Dirk Bruere at NeoPax wrote: > Is it possible to download a Java app (applet etc?) and run it inside a > desktop Java app? > Quite likely, but you won't necessarily get the same security model, unless you were careful about it. -- Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/&g...

java.lang.StringIndexOutOfBoundsException: String index out of range: 23 at java.lang.String.charAt(String.java:460)
Hi All I am having the torque3.1.jar and postgresql-7.4. I have compiled the new jdbc driver called as postgresql.jar and have placed it in the lib directory from where the ant scripts catch the jars. Whenever i try to access through torque gestList = BaseGestlistPeer.doSelect(new Criteria()); this error arises java.lang.StringIndexOutOfBoundsException: String index out of range: 23 at java.lang.String.charAt(String.java:460) at org.postgresql.jdbc2.ResultSet.toTimestamp(ResultSet.java:1653) at org.postgresql.jdbc2.ResultSet.getTimestamp(ResultSet.java...

XML-RPC
Hello, I am getting an error "XML-RPC - java.lang.ClassCastException: java.util.Date" when I call the "XmlRpcClient" execute method. I believe the underlying classes are having trouble parsing the result from the time.xmlrpc.com/RPC2:80 XML-RPC service. I apologize that I could not navigate the Apache bug reporting and search system. I hope someone can recognize what is up with this. Thank you in advance for any help, Michael import java.util.Vector; import java.util.Hashtable; import org.apache.xmlrpc.*; public class GetTime { private final static String serv...

Embed a java-compiler in java.
I'm looking for a (hopefully open-source) java-compiler to embed in a wider java archive. i.e. I need something - a class - that take sources (".java") and libs (".class") and outputs a new archive (".class") without external resources. Moreover it would be good if I could compile data without taking external files (at least for the ".java" files) maybe passing one or more Stringbuffer variables. Thankx. ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World...

java.lang.Set with elements of type java.lang.Set
Roughly I do something along the lines of: Set set = new HashSet(); Set elem = new HashSet(); set.add(elem); // now we change the elem and add it again to the set elem.add(some object here); set.add(elem); I found out the hard way that 'set' may now contain 'elem' either once or twice, the reason being that 'elem.add()' changes the hashCode of elem such that it is not noticed that it is in 'set' already on the 2nd 'set.add()'. Question: What I would actually want is an IdentityHashSet() set = new IdentityHashSet() but this does not...

java.lang.IllegalAccessError: tried to access method Error Message
Looking for help to troubleshoot an java.lang.IllegalAccessError message. I am getting this error message at run time. While searching for this error message I have found that this could be a problem with different versions of the same jar. How do I find out which jar is causing the problem? I will also include my maven pom.xml and services.xml. Thanks in advance for your help. 2008-10-21 14:40:59,630 WARN [http-8080-Processor23] RemoteInvocationTraceInterceptor - Processing of HttpInvokerServiceExporter remote call resulted in fatal exception: com.saic.pf.lib.security.PfLoginManager.log...

java matlab error: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Hello Im using matlab 2010 and 2007 with windows 7 and i have install the new java. Matlab array editor doesnt work right even though i can see the values of an array in the workspace when i try to edit them in the variable editor i cant see the values and i get an error: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at com.mathworks.mlwidgets.array.ValueTableModel.setValuesAt(ValueTableModel.java:195) at com.mathworks.mlwidgets.array.ValueTableModel.setValueAt(ValueTableModel.java:190) at com.mathworks.widgets.spreadsheet.ResizingTableModelWrapper.s...

My LogGenerator.java won't compile - too many errors
[code] package ppowell; import java.io.IOException; /** * Interface * * @version JDK 1.4 * @author Phil Powell * @package PPOWELL */ public interface Loggable { String logFileName = ""; public String getLogFileName(); public void setLogFileName(); public void deleteLog() throws IOException; public void doLog() throws IOException; } [/code] [code] package ppowell; import java.io.*; import java.util.*; /** * Public implementation for LogGenerator to do logging. Singleton Design Pattern * * @version JSDK 1.4 * @author Phil Powell * @package PPOWELL */ public class LogGenerator extends File implements Loggable, Serializable { public static final String TIME_PLACEHOLDER = "#time#", IP_PLACEHOLDER = "#IP#"; public static final String UNIX_LOG_FORMAT = "[#time#]<#IP#> - - "; private String logFileName = ""; private static LogGenerator instance = new LogGenerator(); //---------------------- --* CONSTRUCTOR AND INSTANTIATION METHODS FOR SINGLETON PATTERN *-- ----------------------------- /** * Private constructor. Will instantiate via getter method to ensure Singleton pattern * * @access private */ private LogGenerator() { super(); } // CONSTRUCTOR /** * Instance deliverer * * @access public * @param String fileName * @return LogGenerator instance */ public static LogGenerator getLogGenerator(String fileName) throws FileNotFoundException { // INSTANCE BUILDER ...

to use import java.lang.* or import java.lang.Math or none at all?
Hi guys, i knew that by default all java.lang classes will be imported by the compiler during compilation. but, to make it easier for the computer, should i specify which class i really will be using? does this action will boost the performance during compilation and runtime or not a matter at all? the answer to this post will definitely affect my programming style in the future when i'm considering "to import or not to import"... hmm,,, thanks in advance. JPractitioner wrote: > i knew that by default all java.lang classes will be imported by the > compiler during compilation. but, to make it easier for the computer, > should i specify which class i really will be using? does this action > will boost the performance during compilation and runtime or not a > matter at all? Whether and how you import classes has exactly zero effect at runtime. Imports (with or without wildcards) are only a kind of abbreviation provided by the compiler to save us the effort of typing in fully-qualified type names every time. In theory explicit importing should make compilation faster -- by a very tiny amount. I've never heard anyone claim that they've even managed to measure a difference let alone found a case where it made a practical difference. So the question comes down to how to write your code for maximum clarity. One school of thought asserts that you should always import each class explicitly (rather than by a wildcard). There's a fai...

i'm needing help with compile errors for java GUI enviroment Game of war
>Hi i'm needing some help with compile errors. >This program was allowed by our instructor to be copied out of the book >exactly as it was written except i changed the the name from game of >war to projectJS > >Instructions the program should implement the simple card game of war, >in which the dealer and player each draw a card from the deck. The one >with the highest card wins. The rank is considered when comparing >cards, but the suit is unimportant,so two cards with the same rand >produce a tie. The dealer wins on ties. The opponent is to be given &g...

modifying java.lang.String.java
Hi, I'm trying to modify java.lang.String.java and add the modified String.class to rt.jar [THIS IS FOR MYSELF ONLY AND WILL NOT BE DEPLOYED]. I cannot add "private final boolean tainted[] = new boolean[5];" to String.java. If I do, it still compiles and I can add it to rt.jar and compile a test program against it. However, the JVM crashes with a strange message: java.lang.IllegalArgumentException: name can't be empty at java.security.BasicPermission.init(Unknown Source) at java.security.BasicPermission.<init>(Unknown Source) at java....

java error after OSX java update
Hello all, sorry this is not much of a stats problem, more a computer problem, but I can't find anything about this error on the internet anywhere so thought I'd try here. Basically, the OS X software update system told me there were some updates available this morning (one of which was a Java update). After installing and re-starting, SPSS 16.0.2.1 would not start up again, giving an error: "Cannot launch Java application, Uncaught exception in main method: java.lang.AbstractMethodError: com.spss.java_client.ui.B.=C1(Z)V" Hmmmm.... No idea at all what that might mean, except that it looks like it has something to do with Java.. Anyone else had this problem? Thanks! On May 7, 5:40 am, Hamish <hinnesbr...@gmail.com> wrote: > Hello all, sorry this is not much of a stats problem, more a computer > problem, but I can't find anything about this error on the internet > anywhere so thought I'd try here. > > Basically, the OS X software update system told me there were some > updates available this morning (one of which was a Java update). > After installing and re-starting, SPSS 16.0.2.1 would not start up > again, giving an error: > > "Cannot launch Java application, Uncaught exception in main method: > java.lang.AbstractMethodError: com.spss.java_client.ui.B.=C1(Z)V" > > Hmmmm.... No idea at all what that might mean, except that it looks > like it has somethi...

Web resources about - Java compilation error message. - comp.lang.java.help

KDE Software Compilation - Wikipedia, the free encyclopedia
The KDE Software Compilation ( KDE SC ) is a desktop environment and an associated range of KDE Applications produced by KDE . Prior to version ...

Movie and Gaming Compilations/Tributes - YouTube
Welcome to my channel, I love movies and video games and enjoy making compilation/tribute videos for them. If you have an idea for a video you ...

Animals in Super Bowl Ads: Video Compilation - Special: Super Bowl - AdAge
Cheetahs and horses and bears, oh my! Spots featuring fuzzy, scaly and winged creatures are a time-honored tradition in the Super Bowl. Over ...

Instagram Spotlight Compilations to Shine More Frequently
Instagram launched curated content streams called Spotlight Compilations this past Halloween, and the Facebook-owned photo- and video-sharing ...

A compilation of people hurting themselves on their new Christmas Hoverboards
Hoverboards might not be safe or legal in all places, but they’re definitely popular gifts, especially around Christmas , but controlling these ...

Saetia releasing discography compilation on Touche Amore frontman's label, streaming live album; M/R ...
Short-lived screamo greats Saetia already released the career-spanning compilation A Retrospective in 2001, and this year they'll release another ...

2015 Cute and Funny Animals Compilation
Submitted by: (via kyoot animals ) Tagged: dogs , ducks , cute , Cats , funny , Video , animals Share on Facebook

Compilation: Curry's record-setting 128 3-pointers
... Login Search form Search 58° Navigation Home Giants A's Sharks Warriors Kings 49ers Raiders Quakes Insiders More Tickets Shop Watch Compilation: ...

A Compilation Of Every Time R2-D2 Saved The Day
This is a compilation of every time R2-D2 saves the day in the first six Star Wars movies. He deserves a medal. Without him, pretty much everybody ...

WATCH: New ISIS Video Is Compilation of Beheadings & Hand Amputations
In a new video purportedly released by the Islamic State, footage of previous violence committed by ISIS is set to…

Resources last updated: 3/9/2016 11:56:52 AM