import java.awt.*; 
import java.io.IOException; 

/** 
 * Works for MacOS version 10.11.6 (El Capitan) 
 * openjdk version "11.0.1" 2018-10-16 
 * OpenJDK Runtime Environment 18.9 (build 11.0.1+13) 
 * 
 * 
 * 
 * Fails for MacOS version 10.14.2 (Mojave) 
 * openjdk version "11.0.2" 2019-01-15 
 * OpenJDK Runtime Environment 18.9 (build 11.0.2+9) * 
 * 
 * openjdk version "11.0.1" 2018-10-16 
 * OpenJDK Runtime Environment 18.9 (build 11.0.1+13) 
 * 
 * java version "10.0.2" 2018-07-17 
 * Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13) 
 * 
 * java version "1.8.0_192" 
 * Java(TM) SE Runtime Environment (build 1.8.0_192-b12) 
 * 
 * java version "1.7.0_79" 
 * Java(TM) SE Runtime Environment (build 1.7.0_79-b15) 
 * 
 * The mouse does not move. 
 */ 
public class RobotMouseMove { 

static final double NANO_TO_RAD = 2 * Math.PI / 1_000_000_000d;	// 1 revolution per second 

static public void main(String...args) throws AWTException, InterruptedException, IOException{ 
Robot robot = new Robot(); 

DisplayMode display = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode(); 
int centerX = display.getWidth() / 2; 
int centerY = display.getHeight() / 2; 

System.out.println("Robot Mouse started"); 

long refTime = System.nanoTime(); 
int val = 3; 
if(0 < val){ 
long duration = val * 1_000_000_000L; 
long elapsedTime; 
do{ 
elapsedTime = System.nanoTime() - refTime; 

double angle = elapsedTime * NANO_TO_RAD; 
int x = (int)(Math.cos(angle)*150); 
int y = (int)(Math.sin(angle)*150); 
robot.mouseMove(centerX + x, centerY + y); 

Thread.sleep(8); 
}while(elapsedTime < duration && System.in.available() == 0); 
} 

System.out.println("Robot Mouse stopped"); 

System.exit(0); 
}	
} 