JInput on RaspberryPi - java

I am trying to get JInput working on a raspeberryPi. I know it is not ideal to use JInput without an ide, but the Raspberry Pi is too slow to work with most of them. I have managed to sucessfully compile and run my program from the command line on windows. However, on the pi i am having trouble. The pi is running raspbian, java version 1.7.0_40 with hotspot client vm build 24.0-b56. I have set up the file structure as so:
lib/dist
-jinput-test.jar
-jinput.jar
-Controller
--.dll, .so files
--LinuxEnvironmentPlugin.java
bin
src
I am using the command
java -Djava.library.path=lib/dist/Controller -Djinput.plugins=net.java.games.input.LinuxEnvironmentPlugin -cp bin:lib/dist/jinput.jar:lib/dist/Controller Main
to try and run.
However, i get
"INFO: Failed to load library:" /libjinput-linux64.so: /libjinput-linux64.so: wrong ELF class: ELFCLASSS64"
This is where I am confused. Why is it trying to use the 64 bit file. The rasperry Pi has a ARM version 6 processor, which only works with 32 bit. So why is it looking for the 64 bit file in the first place? I have also tried running with the -d32 option but that doesn't help.

You need a native shared library (JNI) built for the Pi (ARM). Fortunately, there are pre-built raspbian packages for JInput that include the required native library:
sudo apt-get install libjinput-java libjinput-java-doc libjinput-jni
You should also add uinput to the end of /etc/modules so the controller gets detected. If you want a nice GUI to test the controller try also installing:
sudo apt-get install jstest-gtk

you can instal Jinput by
sudo apt-get install libjinput-java libjinput-java-doc libjinput-jni
then find these file on your raspberry pi after installation
jinput-20100502.jar
jinput.jar
jinput-test.jar
libjinput-linux.so
libjinput.so
make a new directory called (let's say) lib in your working directory (a you can name it as you wish)
copy all the files above to the directory lib you just made.
then compile the java file by this way :
sudo javac -cp "/usr/share/java/jinput.jar" Example.java
then run it by this way :
sudo java -Djava.library.path=./lib -cp ./lib/*:. Example
if you make the Example.java from netbeans, remove the package info line at the top. it should work.

• Implemented a workaround.
• Wanted to implement joystick jogging on my Raspberry Pi, Processing3 GUI on a Grbl CNC machine, but hit the JInput <==> ARM incompatibility. Believe Quark is right in asserting that no ARM compatible JInput exists. This is in contradiction to the StackOverFlow thread JInput on RaspberryPi . Tried Albert’s extended apt-get: but no-joy Tried 2021-05-07-raspios-buster-arm64 from https://qengineering.eu/install-raspberry-64-os.html, but processing would not start. Went back to 32bit raspbian.
• Workaround was to add a second Arduino Uno with a USB host shield and run the Logetech 3D Pro joystick off the shield. Modified the Arduino USB Host Shield Library 2.0 le3dp sketch to have all output include an identifying preamble (J0Y) which allows the processing serialEvent to identify which USB port belongs to the Grbl Arduino and which is the joystick Arduino. Working code is at https://github.com/TPMoyer/Grbl4P and https://github.com/TPMoyer/LE3DP_4_Grbl4P

this puts the jar files in /usr/share/java/ which needs to be added to the CLASSPATH. I am still looking for the .so files which need to be added to the LD_LIBRARY_PATH

Related

Unable to install Java tarball. Java binary not found

I was trying to set up a MineOS server on a Raspberry Pi when I ran into an issue where I couldn't update the java version to Java 16. The Raspberry Pi is running the ARM64 architecture and I got my JDK from https://adoptopenjdk.net/releases.html?variant=openjdk16&jvmVariant=hotspot. Here is the specific JDK I downloaded onto my Raspberry Pi: https://github.com/AdoptOpenJDK/openjdk16-binaries/releases/download/jdk-16.0.1%2B9/OpenJDK16U-jdk_aarch64_linux_hotspot_16.0.1_9.tar.gz. To install it and add it to my $PATH, I did:
tar -xf OpenJDK16U-jdk_aarch64_linux_hotspot_16.0.1_9.tar.gz -C /opt/
ln -s /opt/jdk-16.0.1+9/bin/java /usr/bin/java
When running java --version, I get /usr/bin/java: No file or directory. Does anyone know why this is? Before I figured out that Raspberry Pi supports ARM64, I did this on ARM32 and it worked fine, but I needed to be able to allocate more memory to a server, so I had to update to ARM64. If you need more information, I can provide it if necessary.
I did this on ARM32 and it worked fine, but I needed to be able to allocate more memory to a server, so I had to update to ARM64
I assume you mean you are using different Pi now?
On a Pi3, I can do
wget https://github.com/AdoptOpenJDK/openjdk16-binaries/releases/download/jdk-16.0.1%2B9/OpenJDK16U-jdk_aarch64_linux_hotspot_16.0.1_9.tar.gz
sudo tar -xzvf -C /opt OpenJDK16U-jdk_aarch64_linux_hotspot_16.0.1_9.tar.gz
/opt/jdk-16.0.1+9/bin/java --version
Note: tar -xz is for TAR.GZ files, and you only wrote -x in the question...
And that gives me an error about the non-compatible binary, as expected since my Pi needs ARMv7.
From there, I would update the PATH without a symlink, like how is done in Install Java 16 on Raspberry Pi 4
So, that being said, if the file does indeed exist, then there is some other permissions issue you're having
I want the jdk to be stored in /opt/ and easy to remove all of the files related to it.
I see no real need for /opt. If you can use apt/pkg to install, then you can also use it to remove/purge files for it

using java to read data from serial port in Tiny OS

I am going through Tiny OS tutorial lesson number 4 "Mote-PC serial communication and SerialForwarder" and I am stuck on the line where it says
"Once you have installed TestSerial, you need to run the corresponding Java application that communicates with it over the serial port. This is built when you build the TinyOS application. From in the application directory, type
$ java TestSerial
However when I type this, I face the following error
Error: Could not find or load main class TestSerial
I tried several things to fix this issue, but none helped.
Solutions that I tried:
set CLASSPATH to the directory that I am currently in, which is
export CLASSPATH=.:/home/wsn/tinyos-main/apps/tests/TestSerial
2)set CLASSPATH to the directory where tinyos.jar is located
export CLASSPATH=.:/home/wsn/tinyos-main/support/sdk/java/tinyos.jar
3)run command using java -cp . TestSerial
however I keep having the same error
Is there any other better way to fix it?
I am using Virtual Machine with Fedora OS
I am trying to run the program on mib520 platform and I use iris motes
my java version
openjdk version "1.8.0_31"
OpenJDK Runtime Environment (build 1.8.0_31-b13)
OpenJDK Server VM (build 25.31-b07, mixed mode)
You must have skipped the step when you had to run the make command.
Navigate to the apps/tests/TestSerial folder and type make [platform] (such as make telosb, make iris e.t.c), the makefile that will be run will be the makefile in the TestSerial folder which is defined as follows:
COMPONENT=TestSerialAppC
TOSMAKE_PRE_EXE_DEPS += TestSerial.class
TOSMAKE_CLEAN_EXTRA = *.class TestSerialMsg.java
TestSerial.class: $(wildcard *.java) TestSerialMsg.java
javac -target 1.4 -source 1.4 *.java
TestSerialMsg.java:
nescc-mig java $(CFLAGS) -java-classname=TestSerialMsg TestSerial.h test_serial_msg -o $#
TINYOS_ROOT_DIR?=../../..
include $(TINYOS_ROOT_DIR)/Makefile.include
So the makefile compiles TestSerial.java. After this you can proceed to installing the application and then running the TestSerial application.
So step by step on a iris mote for example you would
Navigate to the apps/tests/TestSerial Folder
Make the application by typing make iris
Connect your mote and then type motelist. This command will list all connected motes. The name of your mote should be listed under the "Device" section. Note this for use in the next two steps.
Install your application by typing the command make iris install.1 bsl, [DEVICE NAME]. This will make and upload your program to your device.
Run the TestSerial application by running java TestSerial -comm serial#[DEVICE NAME]:iris
If you use another platform such as telosb then just replace all occurances of iris in the commands above with telosb.

Unable to run threaded java jar file on Mac OS X 10.6.8 with Java 1.7.0.45 using pacifist

I have installed Java 1.7.0_45 on Mac OS X 10.6.8 using Pacifist [http://www.charlessoft.com/] however I am unable to run a jar file which I have downloaded. The jar file is a threaded application.
The error message I am getting is:
java -jar context.jar
2013-10-31 14:14:41.898 java[330:a07] *** NSInvocation: warning: object 0x109356390 of class 'ThreadUtilities' does not implement methodSignatureForSelector: -- trouble ahead
2013-10-31 14:14:41.900 java[330:a07] *** NSInvocation: warning: object 0x109356390 of class 'ThreadUtilities' does not implement doesNotRecognizeSelector: -- abort
Trace/BPT trap
Is there anyway I can run the jar. I have set the JAVA_HOME path properly and java -version is showing 1.7.0_45 as the version.
The same application works properly on Windows Java 1.7.0_45 and also on Linux Java 1.7.
The web search for the solution and the given keywords return very few results and none of them have any specific solution in it. I am new to mac so I am not fully able to understand the issue.
Alternatively, is there anyway I can run Java from folder in Mac like I can do in windows and Linux by just extracting the Java contents and changing the JAVA_HOME. If that is possible then I should be able to run my JAR.
I had kind of same problem while installing an application through jar file, my Java was not detected by the jar application installer,
Over here I see that one of the method is not accessible, could be a same problem. But I am not very sure of it.
make sure you have rt.jar in your JAVA_HOME/jre/lib/ folder
In case you don't have then you are required to have it through the process of creation of symbolic link.
In the command below replace your_java_version with proper version matching your requirement.
sudo mkdir -p /System/Library/Frameworks/JavaVM.framework/Versions/<your_java_version>/Home/jre/lib
Go into the directory:
cd /System/Library/Frameworks/JavaVM.framework/Versions/<your_java_version>/Home/jre/lib/
Create symbolic link :
sudo ln -s ../../../Classes/classes.jar rt.jar
Hope this solves your problem.
I get the exact same problem with MacOS 10.6.8 and JDK 7. In order to run the jar I had to use the System JRE which is 1.6.x (In my case I wanted to install Squirrel
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -jar >squirrel-sql-3.6-MACOSX-install.jar

My Java bluetooth server on raspberry pi running debian wheezy needs bluecove native library - where can I find it?

I have a Java bluetooth server running on a Windows box which I want to port to the Raspberry pi. I have lots of experience with Java but little with Bluetooth or Linux.
The pi currently has Debian Wheezy operating system and I've installed bluetooth and Java ok, and placed the bluecove-gpl and bluecove jars in the classpath.
When I try to run the server, however, Java complains
Native library bluecove_arm not available.
I've tried renaming libbluecove_arm.so from the gpl jar without success, even when setting -Dbluecove.native.path to point to it.
Does anyone know where to find the correct library, what it should be called, and where it should be placed?
[SOLVED}
Found a sh build script on the google code site which showed how to compile the java source files, generate jni headers, compile and link the c files to produce a so library file. Only hiccup was that the library file needed then to be renamed libbluecove_arm.so before it would be found. All done on the pi!
mkdir bluecovelib
cd bluecovelib
wget http://snapshot.bluecove.org/distribution/download/2.1.1-SNAPSHOT/2.1.1-SNAPSHOT.63/bluecove-gpl-2.1.1-SNAPSHOT-sources.tar.gz
tar -zxvf bluecove-gpl-2.1.1-SNAPSHOT-sources.tar.gz
mkdir -p bluecove/target
cd bluecove/target
wget http://snapshot.bluecove.org/distribution/download/2.1.1-SNAPSHOT/2.1.1-SNAPSHOT.63/bluecove-2.1.1-SNAPSHOT.jar
cd ../../bluecove-gpl-2.1.1-SNAPSHOT
ant all
http://privateblog.by/raspberry-pi-kak-rabotat-s-bluetooth-na-java/

How to solve this JNA issue?

I have application which use JNA and gets the audio and video. It works in my Linux box. But when i am testing it in Windows. It just never working. Because i am still learning, i will appreciate your suggestion how to fix it, i already spent few days and weeks only to work it out, but just dont get this why JAVA does not work simply, its a cross platform. Why should it require again System path or etc configuration.
I am totally lost now, why it works in Linux and it does not work in Windows XP ? How can i run it then ?
Inside the lib direcotry i have my JNA and Audio libraries.
C:\Documents and Settings\test\Desktop\test>dir
Volume in drive C has no label.
Volume Serial Number is 680F-0963
Directory of C:\Documents and Settings\test\Desktop\test
19/12/2010 22:09 <DIR> .
19/12/2010 22:09 <DIR> ..
19/12/2010 22:09 51.791 Audio.jar
19/12/2010 22:09 <DIR> lib
1 File(s) 51.791 bytes
3 Dir(s) 487.002.112 bytes free
Now trying to run Audio.jar, gets Fail 1:
C:\Documents and Settings\test\Desktop\test>java -Djava.library.path=~/jni -jar
Audio.jar
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load librar
y gstreamer-0.10
at org.gstreamer.lowlevel.GNative.loadWin32Library(GNative.java:83)
at org.gstreamer.lowlevel.GNative.loadLibrary(GNative.java:43)
at org.gstreamer.lowlevel.GstNative.load(GstNative.java:42)
at org.gstreamer.lowlevel.GstNative.load(GstNative.java:39)
at org.gstreamer.Gst.<clinit>(Gst.java:59)
at video.MyVideo.simpletest(MyVideo.java:31)
at sipphone.MainApplet.run(MainApplet.java:58)
at sipphone.MainApplet.main(MainApplet.java:43)
Fail 2:
C:\Documents and Settings\test\Desktop\test>java -Djna.library.path=. -jar Audio
.jar
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load librar
y gstreamer-0.10
at org.gstreamer.lowlevel.GNative.loadWin32Library(GNative.java:83)
at org.gstreamer.lowlevel.GNative.loadLibrary(GNative.java:43)
at org.gstreamer.lowlevel.GstNative.load(GstNative.java:42)
at org.gstreamer.lowlevel.GstNative.load(GstNative.java:39)
at org.gstreamer.Gst.<clinit>(Gst.java:59)
at video.MyVideo.simpletest(MyVideo.java:31)
at sipphone.MainApplet.run(MainApplet.java:58)
at sipphone.MainApplet.main(MainApplet.java:43)
You'll need to have the DLL installed, or at least in your JNA library path as others have pointed out.
It does add an extra dependency on Windows. It would be an extra dependency on Linux but gstreamer is preinstalled by your distribution. I ran into this same problem when I was making something to use a USB port from Java.
The only solution I know of to avoid the DLL would be to have a second version of the code you could call on Windows that would only use Win32 stuff (i.e. stuff that ships with Windows) but that would be a very large undertaking.
trying to run mediarenderer from cling package, I had the same error on windows xp.
i got the right libgstreamer-0.10.so from package GStreamer-WinBuilds-GPL-x86-Beta04-0.10.7.msi found in https://code.google.com/archive/p/ossbuild/downloads
once installed (environment variables PATH (for dependencies) and OSSBUILD_GSTREAMER_DIR set),
in a prompt, I was finally able to run mediarenderer using the following syntax to introduce lib's path :
Z:\Downloads\cling-distribution-2.1.0\cling-distribution-2.1.0\mediarenderer\target>java -Djna.library.path="C:\Program Files\OSSBuild\GStreamer\v0.10.7\bin" -jar cling-mediarenderer-2.1.0-standalone.jar
hope this helps as a starting point !
For Fail 1: I don't believe that the ~/ syntax will work on Windows. Try %HOME%\ instead. The tilde expansion happens in Bash, so things are a bit different in Windows.
For Fail 2: It doesn't look like the .dll is in your test directory, and you're setting the jna.library.path to ..
If the .dll's are in your lib directory, then shouldn't the paths be set to that directory, instead of ~/jni and .?

Categories