Hello,
I'm attempting to call a method from another class (the method i'm calling is not static) in my own class which extends java.util.TimerTask...I've tried a few thing...but first, let me give you my code as it is currently
import java.util.*;
class myTimerTask extends java.util.TimerTask{
public static void main(String[] args){
run();
}
public static void run(){
CSVFile record = new CSVFile();
CSVFile.getRecord(index);
}
}
In the code above, I get messages saying "run() in myTimerTask cannot override run() in java.util.timerTask; overriding method is static" and "non-static method 'getRecord' cannot be referenced from a static context"...In order to correct the first error I even tried the following to no avail:
public class myTimerTask{
public static void main(String [] args){
TimerTask task = new TimerTask(){
public void run(){
CSVFile record = new CSVFile();
CSVFile.getRecord(index);
}
};
Timer myTimer = new Timer();
myTimer.schedule(task, 5000);
}
}
...would anyone be able to provide any insight as to how to get past static overriding methods, or a way of referencing a non static variable from a static context? Where I'm admittedly a novice, any other suggestions would be appreciated too.