Java universal commands

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

Leave a Reply

Your email address will not be published. Required fields are marked *