Using JRemoteRun
Start jmx agent of remote system by adding following following properties for jvm command line:

Client code, which print Hello world in remote system:
import java.util.*;
import net.sf.jremoterun.CodeForExecutingSupport;
import net.sf.jremoterun.RemoteRunner;

public class Client extends CodeForExecutingSupport {

    public static void main(final String[] args) throws Exception {
        final int jmxPort = 7663;
        final Collection<URL> classpath = new LinkedHashSet();
        final List<Serializable> params = new ArrayList();
        final Serializable classloaderId = net.sf.jremoterun.SimpleFindParentClassLoader.defaultClassLoaderId;
        final Serializable result = RemoteRunner.remoteRunOnLocalHost(
                jmxPort, "user", "password", Client.class, classpath,
                params, classloaderId);
        if (result != null) {

    protected void methodSwitcher() throws Throwable {
        // select which method should be executed
        // runCode3ReturnResult();

    void runCode1Simple() throws Exception {
        System.out.println("Hello World!..");

    void runCode3ReturnResult() throws Exception {
        System.out.println("In runCode2Simple " + new Date());
        result = new Date();