'How do I run a gui Java application headless, without control of the source code?

I want to execute a Jar file using javax swing GUI with 1 radial option, a file selector and a button. The goal is to be able to automate the jar through CLI and select the radial option, file and then click the button.

I do not have access to edit the source of the jar

Is this possible?



Solution 1:[1]

You can look up JAuto, which is a JVMTI agent that is capable of expose UI widget attributes such as class names, screen coordinates. You talk to JAuto by sending a command to a named pipe. It responds by writing a file. A communication scheme like this works in bash scripts.

With the help of xdotool as an input simulator, you can achieve automation under the Linux X11 environment, inside a docker container.

Although depending on the complexity of the Java app, automating it in a headless manner can also be time-consuming. You may also need a VNC setup to inspect program behavior. Checkout this project IBGA and see how it uses JAuto and xdotool to automate a program.

Disclaimer: I'm the author of both JAuto and IBGA.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 He Shiming