Reputation: 2543
I'm interested in compiling and running some java code that works with an api service I'm thinking about subscribing to. I'm a bit of a newbie to java, and I've been trying to get it to work since this morning. Now I'm wondering if anyone here would be willing to help point me in the right direction.
Inside the example folder that comes with all of the code, are the files,
RateService.jar
RateServiceExample.bat
RateServiceExample.class
RateServiceExample.java
(I'm on a mac but the bat script doesn't have anything I've haven't worked with before)
I would like to first compile the code. Inside the java file is the line,
import com.gain.rateservice.*;
I opened up the jar file and sure enough was the directory,
/com/gain/rateservice/
with files
Bup.class
Msg.class
Rate.class
RateService.class
RateServiceListener.class
Sys.class
I try
javac RateSerivceExample.java
And I get,
RateServiceExample is not abstract and does not override abstract method
OnRateServiceMSGMessage(com.gain.rateservice.Msg) in
com.gain.rateservice.RateServiceListener
public class RateServiceExample implements RateServiceListener {
I'm guessing I'm not getting it cause of my newbie-ness. Any help would be greatly appreciated.
Upvotes: 0
Views: 233
Reputation: 2185
In Java if you implement an interface, then you must implement all of the methods of that interface. In your case, this error means that the RateServiceExample class is claiming to implement the RateServiceListener interface, but is not actually implementing all of the methods of the RateServiceListener class.
A short term solution that would just get your code to compile would be to remove the implements RateServiceListener
from the class declaration. So instead your class declaration will look like this:
public class RateServiceExample
But if you actually wish to implement that interface, you will have to fill in your RateServiceExample class with all those methods. Make sense?
To learn more about Java interfaces and inheritance, you can go here.
Upvotes: 1
Reputation: 25269
Posting as answer so I can collect my reputation points:
javac -cp .\RateService.jar RateServiceExample.java
And the .class file is already there so you can probably run it directly:
java -cp .\RateService.jar RateServiceExample
Upvotes: 0