0

java で pdf ファイルを開こうとしましたが、Windows では問題なく動作しますが、Mac では、pdf リーダーが開いていないと、pdf が開きません。

次のようなファイルを開く方法をたくさん試しました。

Desktop.getDesktop().open(file);

また

String[] cmd = new String[]{"/usr/bin/open", file.getPath};
Runtime.getRuntime().exec(cmd);

また、ファイルを開く前にプレビュー (mac pdf リーダー) を開こうとしました:

String openPreview = "/Applications/Preview.app/Contents/MacOS/Preview";
Runtime.getRuntime().exec(openPreview);
String[] cmd = new String[]{"/usr/bin/open", "-a", "preview", file.getPath};
Runtime.getRuntime().exec(cmd);

しかし、何も機能していません... 他にアイデアがなく、なぜ機能しないのかわかりません。

4

0 に答える 0