Reputation: 1
I installed Jnativehook by adding it groupid and artifact id directly to pom.xml in vscode. But when I am importing jnativehook it is not being recognized. I can see the jnativehook package in my maven dependencies. Am I missing something?
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.kwhat</groupId>
<artifactId>jnativehook</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
vscode with jnative example and sharing package installed in maven in bottom left
I tried all possible answers overstackoverflow. Adding the dependencies over pom.xml is not working.
Upvotes: 0
Views: 60
Reputation: 1370
In the pom.xml file I have:
<dependency>
<groupId>com.github.kwhat</groupId>
<artifactId>jnativehook</artifactId>
<version>2.2.2</version>
</dependency>
<!-- Additional libs -->
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-ffi</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.9.0</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>5.9.0</version>
</dependency>
The in my class file I have as imports:
import com.github.kwhat.jnativehook.GlobalScreen;
import com.github.kwhat.jnativehook.NativeHookException;
import com.github.kwhat.jnativehook.keyboard.NativeKeyEvent;
import com.github.kwhat.jnativehook.keyboard.NativeKeyListener;
As you can see in the image below, it worked for me.
So instead of trying to import from org.jnativehook
, try importing from com.github.kwhat.jnativehook
instead.
Upvotes: 0