I am still trying to get my Bluetooth controller working on my pi with Java. I found the project jinput from https://github.com/jinput/jinput and installed the dependencies:
sudo apt-get install libjinput-java libjinput-java-doc libjinput-jni
When I run the test class it is working:
sudo java -Djava.library.path=/usr/lib/jni -cp /usr/share/java/jinput.jar:/user/share/java/jinpu-test.jar net.java.games.input.test.ControllerTextTest
but however, when I am using my project I compiled on my Windows 64Bit system, on the linux system I always get the error:
Failed to load library: no jinput-linux64 in java.library.path
Trying to run it the same way:
sudo java -Djava.library.path=/usr/lib/jni -cp /usr/share/java/jinput.jar -jar /home/robot/MyFirstProgram.jar
I don't understand the difference, so I assume it is related maybe to the build.gradle
//Gradle file
plugins {
id 'java'
id 'eclipse'
id 'idea'
id "net.ossindex.audit" version "0.4.5-beta"
id "com.github.johnrengelman.shadow" version "4.0.3"
id 'org.hidetake.ssh' version '2.10.1'
}
version = '2.6.0'
// Project definitions
repositories {
mavenCentral()
maven {
url "https://jitpack.io"
}
maven {
url "https://repo1.maven.org/maven2/"
}
maven {
url "http://oss.sonatype.org/content/repositories/releases"
}
maven {
url "http://oss.sonatype.org/content/repositories/snapshots"
}
}
configurations {
// configuration that holds jars to include in the jar
extraLibs
}
dependencies {
implementation("org.slf4j:slf4j-simple:latest.release")
implementation("com.github.ev3dev-lang-java:ev3dev-lang-java:latest.release")
//extraLibs group: "net.sf.bluecove", name:"bluecove", version:"latest.release"
//extraLibs group: "net.sf.bluecove", name:"bluecove-gpl", version:"latest.release"
implementation( group: "com.github.hypfvieh", name:"bluez-dbus-parent", version:"0.1.4")
implementation( group: "com.github.hypfvieh", name: "bluez-dbus", version: "0.1.4")
implementation( group: "net.java.jinput", name:"jinput", version: "2.0.9")
extraLibs group: "br.com.criativasoft.opendevice.ext", name:"bluecove", version:"2.1.1-SNAPSHOT"
extraLibs group: "br.com.criativasoft.opendevice.ext", name:"bluecove-gpl", version:"2.1.1-SNAPSHOT"
extraLibs group: "br.com.criativasoft.opendevice.ext", name:"bluecove-gpl-arm", version:"2.1.1-SNAPSHOT"
configurations.compile.extendsFrom(configurations.extraLibs)
}
apply from: './config.gradle'
compileJava.options.encoding = 'UTF-8'
//Compile
compileJava {
sourceCompatibility = 11
targetCompatibility = 11
}
//Jar
jar {
baseName = "${rootProject.name}"
manifest {
from file("${projectDir}/src/main/resources/META-INF/MANIFEST.MF")
}
}
task fatJar(type: Jar) {
manifest.from jar.manifest
classifier = 'all'
from {
configurations.extraLibs.collect { it.isDirectory() ? it : zipTree(it) }
} {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
with jar
}
fatJar.dependsOn shadowJar
apply from: './config.gradle'
apply from: './gradle/deploy.gradle'
Can someone please help me with that?
Thanks
Stephan
Edit: Just to be clear. I only run my code on Linux, but use VSC on Windows to write and compile the jar file
Edit2: I found this https://github.com/SteveSmith16384/jinputtest/blob/master/libs/libjinput-linux64.so which I copied in the required folder and is running without any issue. However, I still don't understand why I can run the local jar file, but not my compiled one.
I created a link
jinput-linux64
to/usr/lib/jni/libjinput
. Ugly, but it worked for me.