2014-07-22 47 views
0

編輯:---- 我需要批量處理來自我的JavaFX應用程序的一些處理草圖文件。下面的代碼在Windows上工作。我想讓它在Mac上運行,但不知道如何。JavaFX。如何從終端OSX運行處理

我的工作流程如下:

//as the user for the processing-java.exe file 

processingJavaProrgramFile = fileChooser.showOpenDialog(stage); 
if (processingJavaProrgramFile != null) { 
    processingJavaProrgramPath = processingJavaProrgramFile.getPath(); 
} 



//ask the user for the processing sketch folder 

processingSketchDir = directoryChooser.showDialog(stage); 
if (processingSketchDir != null) { 
    sketchPath = processingSketchDir.getPath(); 
} 



//java run time exec method to compile sketch in user folder using through processing-java.exe 

Runtime.getRuntime().exec(
    processingJavaProrgramPath + 
    " --force --run --sketch=" + 
    sketchPath + " --output=" + 
    sketchPath+File.separator + 
    "temp" 
); 

我如何得到它在Mac上運行?首先,Mac版本沒有處理java.exe。它應該是一個不同的工作流程?如果是這樣,我該如何讓應用程序知道它是在Windows還是在Mac OS上運行,以便它運行適當的方法?

+0

發佈[MCVE](http://stackoverflow.com/help/mcve)以及您看到的具體錯誤,我們將從此處繼續。 –

回答

1

好吧找到了解決我的兩個問題。

要得到操作系統類型,我使用的方法here

要在Mac上運行有相同的代碼處理,我需要:

加工而成,轉到工具菜單並安裝「處理的Java」 。這以某種方式將其安裝到系統中。因此,在Mac情況下,用戶不需要選擇Windows中處理java的路徑(選擇processing-java.exe)。在Mac上,用戶只需要選擇輸出文件夾。