「外部アプリケーションの起動」の編集履歴(バックアップ)一覧はこちら
「外部アプリケーションの起動」(2009/05/14 (木) 14:05:23) の最新版変更点
追加された行は緑色になります。
削除された行は赤色になります。
SWT
Program program = Program.findProgram(".html");
if (program != null) {
program.launch(strUrl);
}
外部アプリ起動 SWT
Program program = Program.findProgram(".html");
if (program != null) {
program.launch(strUrl);
}
外部アプリ起動 Java1.6
if (!Desktop.isDesktopSupported()) {
return;
}
Desktop desktop = Desktop.getDesktop();
//
if (desktop.isSupported(Desktop.Action.OPEN)) {
File file = new File("C:\\test.txt");
desktop.open(file);
}
外部アプリ起動 Java1.5
String[] command = { "notepad.exe"};
ProcessBuilder builder = new ProcessBuilder(command);
builder.directory(new File("C:\\temp"));//作業フォルダの設定
Map<String, String> env = builder.environment();//環境変数を取得
Process process = builder.start();
InputStream stream = process.getErrorStream();
while (true) {
int c = stream.read();
if (c == -1) {
stream.close();
break;
}
System.out.print((char) c);
}