是否可以从 Java 应用程序运行 Kettle Job/Transformation,然后在同一个Java 应用程序中获取结果(例如变量)?
问问题
3001 次
2 回答
2
尽管从 Java 中执行命令行可能并不理想,但下面会起作用。只需将 cmd 行替换为适当的路径并读入作业的输出文件即可。
public static void main(String[] args) {
try {
String cmd = "\"c:\\Program Files\\Pentaho\\pdi-ce-5.0.1.A-stable\\data-integration\\kitchen.bat\" -file=\"c:\\users\\exampleuser\\desktop\\examplejob.kjb\"";
System.out.println(cmd);
Process process = Runtime.getRuntime().exec(cmd);
process.waitFor();
} catch (Exception e) {
e.printStackTrace(System.err);
}
/*READ OUTPUT FILE OF KJB IN TO OBTAIN VALUES*/
}
* http://forums.pentaho.com/showthread.php?81151-Tutorial-Using-command-line-arguments-with-Kettle-and-scheduling * http://docs.oracle.com/javase/tutorial/java /data/strings.html * http://wiki.pentaho.com/display/EAI/.01+Introduction+to+Spoon * http://javarevisited.blogspot.com/2011/02/how-to-execute- native-shell-commands.html * http://www.mkyong.com/java/how-to-execute-shell-command-from-java/
于 2014-02-23T15:35:05.700 回答