Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.awt.Robot works strangely under macOS Mojave

3881919Feb 10 2019 — edited Feb 10 2019

After macOS was upgraded to Mojave, java application that is using Java Robot and works absolutely fine under High Sierra, stars to work incorrectly. Symptoms are:

  • robot.keyPress(VK_N); causes about 7 the same errors and did not type anything.

2019-02-03 19:27:52.324 java[928:31672] pid(928)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is is NOT allowed. Please call TIS/TSM in the main thread!!!

  • robot.mouseMove works fine if I run it via Java command line, and doesn't work if I run the same class in Eclipse.

public static void main( String[] arg) throws AWTException, InterruptedException {
  
Robot robot;
  robot
= new Robot();

  robot
.waitForIdle();
  robot
.keyPress(VK_N);
  robot
.keyRelease(VK_N);

  robot
.waitForIdle();
  robot
.mouseMove(100, 100);
  
Thread.sleep(500);
  robot
.mouseMove(10, 10);
}
 

According to the recommendation Robot.mouseMove does not work at all in Mac OS X I have added Java and Eclipse into Security & Privacy, click the Privacy tab toward the top, then choose Accessibility. It did not solve the problem. Moreover, I could not see any difference.

I went through this link https://eclecticlight.co/2018/09/17/managing-mojaves-privacy-protection-privacy-controls/ and ran "tccutil reset AppleEvents". But I did not get expected the dialog to add the pair of apps into Privacy=>Automation section of "System preferences"

my Java is 1.8.0_191, x86_64.

Any ideas on how to get that code to work in Mac OS Mojave?

Best Regards,

Comments

Post Details

Added on Feb 10 2019
0 comments
2,265 views