I've been trying to use the Robot class over a network with a server opening notepad and typing some words in on the client desktop though the most I have been able to achieve is to open notepad and even then my client gives an error, the server continues to run until I shut notepad though gives an error too. "HELOWORLD" instead of "HELLOWORLD" is the output wherever the key cursor is resting even if inside the client code, notepad is left empty. Can anyone please help.

import java.net.*;
import java.io.*;
 
public class Server{
public static void main(String[]args)throws IOException{
	ServerSocket serverSocket = new ServerSocket(8976);
	Socket socket = null;
	ObjectOutputStream out = null;
 
	try{
		socket = serverSocket.accept();
		out = new ObjectOutputStream(socket.getOutputStream());
		out.writeObject(new ControlObject());
	}catch(IOException e){
		e.printStackTrace();
	}finally{
		out.close();
		socket.close();
	}
}
}
import java.io.*;
import java.net.*;
 
public class Client{
	public static void main(String[]args)throws IOException, ClassNotFoundException{
		final Socket socket = new Socket("127.0.0.1",8976);
		final ObjectInputStream in = new ObjectInputStream(socket.getInputStream());
 
 
 
	    try {
		    Object s = in.readObject();    
		}catch(IOException e){
			e.printStackTrace();
		}finally{
			in.close();
            socket.close();
 
		}
 
 
 
	}
}
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.io.Serializable;
 
public class ControlObject implements Serializable{
	public ControlObject() throws IOException {
		try {
			int KeyInput[] = {
					KeyEvent.VK_H,
					KeyEvent.VK_E,
					KeyEvent.VK_L,
					KeyEvent.VK_L,
					KeyEvent.VK_O,
					KeyEvent.VK_W,
					KeyEvent.VK_O,
					KeyEvent.VK_R,
					KeyEvent.VK_L,
					KeyEvent.VK_D,
			};
			Robot robot = new Robot();
			robot.delay(5000);
			Runtime.getRuntime().exec("notepad");
			robot.keyPress(KeyEvent.VK_SHIFT);
			for(int i = 0;i<KeyInput.length;i++){
				robot.keyPress(KeyInput[i]);
			}
 
			robot.keyRelease(KeyEvent.VK_SHIFT);
		} catch (AWTException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
 
	}
}