You can do this in several ways; however, almost every path is connected to a network connection.
You can write a couple of programs for a Java client with a client connection to the server and send a command.
You can write your Java to use an existing server, such as sshd, telnetd, rsh, ftpd, or a pre-existing other server that allows commands at the remote end.
You can use an architecture that handles certain aspects of creating a client-server pair, such as RMI, SOAP, CORBA, etc.
After all, Java supports many network options, so you have more ways to do this than you think. Just make sure you don't do this in a web browser, as these JVMs run in the sandbox, and you cannot exit the sandbox without any help.
source share