I have a java program where I wrote a scheduler, or a timer where once it starts running. It will call the function every N minutes interval indefinitely. For now, I set N to 5 minutes.
I want to sent out this program in a form of jar file along with some sort of properties file where the tester or anyone else can configure N; so it's much more convenient and I do not have to change in the code itself.
This is an example:
public void schedule() throws Exception {
Timer t=new Timer();
t.scheduleAtFixedRate(
new TimerTask() {
@Override
public void run() {
// System.out.println("HELEOELE");
try {
test.index();
} catch (Exception e) {
e.printStackTrace();
}
}
},
0,
300000);
}
In this case, N = 300000.
I am not too familiar with jar file but I do have a properties file with db connection created.
This is how I called the properties:
Properties props=new Properties();
InputStream in = getClass().getResourceAsStream("/config.properties");
props.load(in);
in.close();
int value=Integer.parseInt(props.getProperty("value"));
So I would appreciate is there any way to do this?