문제

I'm writing a application which I would like to be able to do certain tasks with the computer.

As an example I could use:

runCommand("shutdown.exe", "-s -t 01");

to shutdown, but that would only work if the program is executed on Windows XP or later.

Is there a way to make Java perform some tasks that are universal and will work on every operating system that has Java installed? Like the shutdown command.

도움이 되었습니까?

해결책

Short answer: No. Commands like the one in the example are absolutely specific to the host operating system, and are not portable across platforms. You'll find some degree of compatibility among related OSs, for example in POSIX-compliant Unix operating systems

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top