星期四, 4月 23, 2020

[Eggplant] 使用shell指令執行Java Jar

測試如何shell執行java包出的jar檔應用,並把執行結果取出。

測試一般jar檔執行

MacBook-Pro-8:eggplant_cmd bigd$ java -cp JarDemo.jar com.test.jardemo.TestJar "Hello World" "Ken"

輸入參數0:Hello World

輸入參數1:Ken


//存放shell輸出的東西
set destinationFile to "/Users/bigd/Downloads/shellOutput.txt"

//Users/bigd/Downloads/eggplant_cmd
shell "java -cp /Users/bigd/Downloads/eggplant_cmd/JarDemo.jar com.test.jardemo.TestJar 'Hello World' 'Ken' >"  & destinationFile

put file destinationFile into shellOutput
//LogSuccess file destinationFile
log shellOutput

//砍掉檔案
delete file destinationFile



參考

沒有留言:

張貼留言

留個話吧:)