私のエラーがどこにあるかを知るためにあなたの助けが必要です:)
public class Main extends JFrame{
public Main() {
EventQueue.invokeLater(new Runnable() {
public void run() {
setVisible(true);
}
});
}
public static void main(String[] args) throws IOException, URISyntaxException {
new Main();
File executor = File.createTempFile("Executor", ".sh");
PrintWriter writer = new PrintWriter(executor, "UTF-8");
writer.println("#!/bin/bash");
writer.println();
writer.println("java -$* > /tmp/output.txt 2>&1 &"); // ***
writer.close();
executor.setExecutable(true); // ***
File elevator = File.createTempFile("Elevator", ".sh");
writer = new PrintWriter(elevator, "UTF-8");
writer.println("#!/bin/bash");
writer.println();
writer.println(String.format("osascript -e \"do shell script \\\"%s $*\\\" with administrator privileges\"",
executor.getPath()));
writer.close();
elevator.setExecutable(true); // ***
Runtime.getRuntime().exec(String.format("%s -cp %s Main param", // ***
elevator.getPath(),
Main.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()));
}
}
このコードは、管理者権限でアプリケーションを新たに実行することを想定しています。管理者パスワードが求められますが、その後、アプリケーションは実行されません。なんで ?出力にエラーはありません
ありがとうございました