2012-02-28 87 views
0

採取的程序名調度Java程序這是我做了什麼..從Derby數據庫

mgr.addAlarm(new AlarmEntry("ComplexCron2",new int[]{dtime,10,28}, new int[]{16}, new int[]{-1}, new int[]{-1}, new int[]{Calendar.TUESDAY}, -1, new AlarmListener() { 
    public void handleAlarm(final AlarmEntry entry) { 


     Addempnew.main(null); 
    System.out.println("\u0007Cron complex2 (" + new Date() + ")"); 
    } 
})); 

這裏Addempnew.main(空)是一個Java程序,我想安排它。但不是直接使用程序名稱,而是想從數據庫中獲取它。

+0

你用quartz-scheduler標記了你的問題。還有什麼要補充的? – 2012-02-28 10:59:40

+0

這裏可以只調度Addempnew.main(null);但我需要通過從數據庫中取得他們的名字來安排任何java文件 – Anuradha 2012-02-28 11:05:24

回答

0

你必須

// 1. Load class Addempnew: 
Class cl=Class.forName("Addempnew"); 
//Exceptions may occur, catch them. 

// 2. retrieve static method main(String[]) via reflection: 
Method m=cl.getMethod("main", String[].class); 

// 3. call retrieved method via reflection: 
m.invoke(null, null); 

所有這些步驟都在別處描述。