[I FOUND SOLUTION]Automation does not work if I run it from JAR but it works if I run it from IDE

The problem was with the dependency of java client.
To be exact I had java client 9.2.2 but inside of it I had selenium 4.14.1 inside of it. Locally it worked fine but in jar it could not create Driver in my case.
So I came across with this table GitHub - appium/java-client: Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol looked up compatible java client version for selenium 4.14.1 which is java client 9.0.0 and suddenly everything worked fine in jar file

See here is the dependency, but instead of 9.0.0 it was 9.2.2

I just changed version to 9.0.0 here

Guess its skill issue from me :pensive:

I have a separate app which launches automation scenario via REST API. It gets from request the ADB id of the device then it creates AndroidDriver and it works ONLY IF it was launched In IDE. If I launch it from JAR it will ENDLESSLY hang on AndroidDriver line of code. Also there are no reaction from the Appium server (which I launch from cmd) not a single message.

Here is the API endpoint
public class ServerAndroidConnectionController {

public void establishConnection(@PathVariable("adbDeviceId") String adbDeviceId,@PathVariable("deviceId") String deviceId, @PathVariable("deviceName") String deviceName) throws IOException, InterruptedException {

    DeviceInfo deviceInfo = new DeviceInfo();
    System.out.println("DEVICE ID: " + deviceId);
    System.out.println("DEVICE NAME: " + deviceName);

    AutomationExecutor executor = new AutomationExecutor();
    //executor.executeTransfer(adbDeviceId, deviceInfo);

    // Создаем CompletableFuture для асинхронного выполнения
    CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
        try {
            executor.executeTransfer(adbDeviceId, deviceInfo);
        } catch (IOException | InterruptedException e) {
            throw new RuntimeException(e);

    // Устанавливаем таймаут в 2 минуты
    future.orTimeout(2, TimeUnit.MINUTES);

    // Добавляем обработчик для случая, когда таймаут истекает
    future.whenComplete((result, ex) -> {
        if (ex!= null) {
            // Обработка исключения, если таймаут истек
            //System.err.println("Таймаут истек");
            throw new RuntimeException(ex);
        } else {
            // Обработка успешного завершения
            System.out.println("Выполнение успешно завершено");



And the method that returns driver where it hangs after message “RETURNING DRIVER” without any exceptions in the code and in the appium server

public static AndroidDriver initDevice(String adbDeviceId) throws
MalformedURLException {

    String address = "";
    InetAddress inetAddress;
    try {
        inetAddress = InetAddress.getLocalHost();
    } catch (UnknownHostException e) {
        throw new RuntimeException(e);
    System.out.println("AFTER ADDRESS");

    address = inetAddress.getHostAddress();
    System.out.println("ADDRESS " + address);

    AppiumServiceBuilder builder = new AppiumServiceBuilder();
    builder.usingDriverExecutable(new File("C:\\Program Files\\nodejs\\node.exe"))
            .withAppiumJS(new File("C:\\Users\\Kolgotik\\AppData\\Roaming\\npm\\node_modules\\appium\\build\\lib\\main.js"))

    try (AppiumDriverLocalService service = AppiumDriverLocalService.buildService(builder)) {
       // service.start();
        URL serviceUrl = service.getUrl();
        System.out.println("APPIUM URL: " + serviceUrl.toString());

        System.out.println("AFTER CAPABILITIOS BEFORE OPTIONS");
        UiAutomator2Options options = new UiAutomator2Options()

        System.out.println("BEFORE ADDRESS");

        URL url = new URL("http://" + address + ":4723/");

        System.out.println("RETURNING DRIVER");

        AndroidDriver driver = new AndroidDriver(service, options);
        return driver;
    } catch (IOException e) {
        throw new RuntimeException(e);