5

I am trying to build a simple maven based app for automated testing using SikuliX. The app is currently created as a most recent spring-boot application (v. 1.4.1). The app itself is rather simple (POC at the moment), one class as an Application (SpringBootApplication annotated, implementing CommandLineRunner) and one service (autowired, impl and interface). Nothing more, no other dependencies (just SikuliX, commons-lang3 and spring-boot-starter).

However, when I do run the app, Sikuli subsystem complaints about being run in headless mode.

I have tried using SpringApplicationBuilder.headless(false).web(false).run(args); setting System.setProperty("java.awt.headless", "false"); passing arguments to the JVM to disable headless mode. None of the options alone works as well as their combination. Spring-boot always assumes headless mode.

Is there anybody who come across issue like this?

PS: os is mac and windows, java 1.8

Have a nice day folks.

J.

johnnnie
  • 71
  • 7
  • 3
    Make sure that `System.setProperty("java.awt.headless", "false");` is the first thing you do in the `main` method. As the value of that property will be used if set else it does a fallback to `headless`, so if it first detects the property and sees `true` regardless of the setting of `false` for `headless` it still will be `true`. See – M. Deinum Oct 13 '16 at 12:47
  • Do you have a custom banner image? I noticed that Springboot forces `java.awt.headless` to `true` when I have a `banner.jpg` in my resources – Hans Bogaards Jan 19 '18 at 08:41

2 Answers2

2

I was having the same issue and fixed it by setting the java.awt.headless system property to false. This is the suggestion from M. Deinum in a comment to the OP so credit to them.

Here is how I added it to my main application file:

public static void main(String[] args) {
    System.setProperty("java.awt.headless", "false"); //ADD THIS
    SpringApplication.run(MyClass.class, args);
}
flowjoe
  • 105
  • 8
0

Sikuli cannot be run in a headless mode. This is a known limitation. The reason for that is the Java Robot library that is being used internally by Sikuli. In other words, you must have a running machine with a screen to make Sikuli work.

Eugene S
  • 6,709
  • 8
  • 57
  • 91
  • 1
    Hi Eugene, I do run the app on my desktop and the problem I have is the fact that I can not force it to run with head, somehow jvm/app thinks it runs in headless mode, regardless passed jvm parameters, system properties or spring-boot setup. – johnnnie Oct 13 '16 at 09:24