Part-II: OwnCron-A lightweight Java Tool ...Leverage Scheduling your Java Business logic an out-of-the-box way
In continuation to https://www.garudax.id/pulse/owncron-a-lightweight-java-tool-leverage-scheduling-your-sengupta, let us now face the reality: that Business Codes are never in a simple Java class but rather we may expect them to be packaged within one or more JAR files . So, scheduling annotated business methods of a stray class shall not cater to real life.
However, as I told earlier, the following release would include loading classes from archives (E.g. JAR , WAR , EAR etc.) , let us quickly see this in action.
Please get the newer release JAR
I add the following method to the class MyGoodClass
//@author: sohamsg
// Opens google.com in default browser in every 5 minutes
@IA1("0 */5 * * * *")
void openGoogleInBrowserWindows() throws Exception{
Runtime.getRuntime().exec("cmd /c start https://google.com").waitFor();
}
Then I archived the c using the usual JAR utility
jar -cvf test1.jar *.class
Used the following simple command
java -classpath ".;D:\abc\test1.jar" -Dapp.class.name=MyGoodClass -Dapp.annotation.class.name=IA1 -jar EasyCron-0.0.2-SNAPSHOT.jar
It works as expected, opening google.com in the default browser every 5 minutes
To test the above readily, please download the JAR and the library JAR , and modify the above command according to locations on your files system where the