可以从 Java应用程序运行 Kettle Job / Transformation ,然后在同一Java App中获取结果(例如变量)?
答案 0 :(得分: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/
答案 1 :(得分:-2)