答案 0 :(得分:0)
看起来您需要将NSWorkspace类映射到JNA。定义在JNA中扩展Library类的接口。然后将setDesktopImageURL:forScreen:options:error:
方法映射到JNA。
答案 1 :(得分:0)
如果没有JNA,你可以这样做。
public void setWallpaper(File file)
throws Exception {
String as[] = {
"osascript",
"-e", "tell application \"Finder\"",
"-e", "set desktop picture to POSIX file \"" + file.getAbsolutePath() + "\"",
"-e", "end tell"
};
Runtime runtime = Runtime.getRuntime();
Process process;
process = runtime.exec(as);
}
积分