I have a Raspberry Pi 2, and an arduino pro micro set up as a Joystick. On the Pi i have a java application that runs well on a PC with both Linux and Windows with the arduino joystick connected. But as soon as I start running the program on the pi I get an error message like:
`Failed to load library:" /libjinput-linux64.so: /libjinput-linux64.so`
After some googling around i find that the problem is that the Jinput library is not compiled to run on ARM processors:
JInput on RaspberryPi
So far so good, but this far I could not find a solution as to how I get the .so file compiled to run on the arm processor. I guess it is somewhat trivial for someone with the knowledge, since the file is easily decompiled and the project is open source.
But I have been stuck at this stage for the last 1½ month. Any help as to how to compile it where to find the files that are to be compiled and such, or alternatively finding an already compiled file for the raspberry pi 2 would be helpful.
Not a direct answer about how to compile JNI libraries, but there appears to be a pre-compiled version available on Raspbian:
> apt search jinput
Sorting... Done
Full Text Search... Done
libjinput-java/stable 20100502+dfsg-7 all
Java Game Controller API
libjinput-java-doc/stable 20100502+dfsg-7 all
Java Game Controller API (javadoc)
libjinput-jni/stable 20100502+dfsg-7 armhf
Java Game Controller API (jni)
So the solution may be to just apt install libjinput-java; this will probably include the -jni package as a dependency (see here).
Related
Im new to app development and was wondering if it would be possible to include another jdk. For example java 17 and run a jar that needs to be run in this exact version? I think termux has an api that you may use for these purposes but is there another possibility? These jars are only console based and without any gui.
I first tried to use the jar as a android library inside the app, which did not work since it was compiled in java version 17. I tried decompiling the jar and recompiling it with the version I was using. The problem is that all the libraries used are on other versions than I need them to be and so I could not recompile it. I also thought about writing the application in c# but I am not used to it at all, which would throw many new problems that I would be willing to take if it would be a possibility to work out my project.
Q: Is loading the code into your Android application an option?
A: No.
Android loads code from ".dex" files not ".class" files.
The ".class" files would need to be translated using dx.
The Android dx command doesn't understand Java 17 ".class" file format.
Also the code in the JAR is likely to depend on classes in the Java SE class library that the Android doesn't provide.
Q: What about running it in a separate Android VM?
A: No.
An Android VM requires ".dex" files; see above.
Also, the Java SE class library issue; see above.
Q: What about launching an OpenJDK or Oracle Java 17 JVM on the Android device to run the JAR?
A: In theory Yes, but in practice No. As far as I am aware, there is no port of OpenJDK Java SE to the Android OS platform.
Q: What about using Termux?
A: OK ... that might work. See Is it possible to install the JDK on an android device?.
I have no experience with this, and don't know what problems you may run into doing this. But I suspect that you wouldn't be able to distribute something that relies on Termux via the Google Playstore.
Another option is to download the source code1 for the application and try to build it in your Android dev environment
If the code uses Java classes / packages / libraries that are not available for Android, recode the relevant parts of the application to use Android equivalents instead.
Ditto if the code uses Java language features that are not yet supported in Android Java.
It probably won't be easy. It may turn out to be impractical.
1 - You said in a comment that the code your are trying to use is "open source". So the "download source and build it" option is available to you. I'm puzzled why you tried to decompile and recompile it instead ...
I'm trying to use the C++ library Spot (https://gitlab.lrde.epita.fr/spot/spot) in a Java project. I wanted to realize the interface between Java and C++ with JNA (https://github.com/java-native-access/jna). Because the Java application should also run on Windows, I tried to cross compile the library first with
./configure --host=x86_64-w64-mingw32 --disable-python LDFLAGS="-static -static-libstdc++ -static-libgcc"
and then of course make/make install on a Linux system. Because I can't expect the Windows system to have libstdc++/libgcc I wanted to link it statically into the library. My problem is now the following: When I try to open an compiled .exe in Windows, it still tells me libstdc++/libgcc not found. Of course, JNA also gives me an UnsatisfiedLinkException when I try to load the library in my Java program, because the modules are still not found, even though i explicitly linked them statically.
So what am I doing wrong? What else can I try to avoid having libstdc++/libgcc installed on the host system? I am now trying this for a week and have no clue how to overcome this, so a question here is kind of my last resort.
Thanks
I'm using ImageJ for image processing for a class, and I've been creating small plugins for a few weeks. It's been frustrating for me because I never saw any java error messages, such as syntax error on line 3 blah blah. When my plugins don't compile (due to some compile time error), all I see is "class not found", or if a plugin had compiled in the past and there is a class file available it will run the old compiled version and not give me any error.
I thought this was normal until I met up with my friend and he had been getting error messages the whole time.
Any idea why this is? I'm using windows (tried on windows 10, 8, and 7), he's using some osx distribution (most likely the latest). I've tried all available versions of ImageJ from the website, so I don't think it's a version issue. Is this the norm on windows for some reason?
I suspect you are using ImageJ 1.x, e.g. downloaded from here? And trying to compile via Plugins>Compile and Run...?
In general, I would recommend developing Java code in Eclipse - as having a proper IDE is vastly more powerful than what you can get in ImageJ.
If all you need to do is write simple Macros calling existing ImageJ functions then writing them in the various non-Java scripting languages within ImageJ is perfectly sufficient.
If you decide Eclipse isn't your thing and you want to continue developing within ImageJ, I would strongly recommend using the Fiji distribution of ImageJ - as it includes a robust script editor.
If you use this editor to write Java code, it will save your scripts to disk as .java files and then call the Java compiler (javac) on them, which will give you a more complete picture of any compilation problems.
I recently got a Raspberry Pi 2 and have been trying to get a program using Java/Java 3D that I've used before on the previous Model B to run on it.
The Pi is running Raspbian, and I've installed the libjava3d-java and libjava3d-jni packages.
I've copied the following files into a lib folder:
j3dcore.jar
j3dutils.jar
vecmath.jar
libj3dcore-ogl.so
I've then included -Djava.library.path="lib/*" in the command I use to run my program, but I'm getting an UnsatisfiedLinkError: no J3D in java.library.path
Could there be any other files that I need? Might I have an incorrect version of the native libraries? All the files I've put in the lib folder are ones that I've found in the system as installed by the package manager.
Thanks for reading
I assume that you're trying to install an obsolete version of Java3D (1.5.2 or earlier). Please follow these instructions to download and install Java3D 1.6.0.
Java3D uses the fixed pipeline, it is designed to use OpenGL whereas the Raspberry Pi supports OpenGL ES. Java3D 1.6.0 uses mostly the same public API than Java3D 1.5.2 and we have done no change to make it work with OpenGL ES. It has a very few chances to work as is on your device.
Rather use JMonkeyEngine 3, LibGDX or JogAmp's Ardor3D Continuation with its JOGL renderer. The two first ones work with the Raspberry Pi for sure, the last one still needs some work.
Edit.: You have a chance to make it work with Eric Anholt's driver, it already works with Processing 3 on a Raspberry Pi 2: http://labb.zafena.se/?p=972
I have Kinect for xbox. I have installed Kinect SDK.
I am trying to program Kinect using Java in Eclispe IDE. I have tried several tutorials. I have installed:
openni-win64-1.5.4.0-dev.msi
nite-win64-1.5.2.21-dev.msi
SensorKinect092-Bin64-v5.1.2.1.msi
sensor-win64-5.1.2.1-redist.msi
and it didn't work, when I run NiSimpleRead it open and then close immediately.
also I have tried to install all above but win32 and it also didn't work.
I have installed ZigFuOpenNI.exe and the problem still exists.
I have tried the tutorial installation of J4K library using the instructions in this site:
http://research.dwi.ufl.edu/ufdw/j4k/eclipse.php
and also it is not working it seems that there is problem with jogl and gluegen-rt native libraries because when I open the folders in the Package Explorer they are empty, but I am following the instructions correctly.
In my case, Kinect only works with Processing 2.2.1. I have tried the examples in this program using SimpleOpenNI and it works.
My question is how can I connect Kinect to Java in Eclipse.
I would be very much appreciated for helping me.