[SOLVED] Development on Raspberry Pi 4

It runs a little clunky, but should be enough to continue developing. Hopefully I won’t have any issues. I don’t know if the frame rate would improve if I was running GL ES 3 instead of GL 2. But as long as I can develop I’m happy.

Let me know if you want help with getting GL ES to the pi.

3 Likes

There’s a new pull request to define the relevant Platform values: define 2 new Platform values for Linux ARM, register BulletJme lib paths by stephengold · Pull Request #1182 · jMonkeyEngine/jmonkeyengine · GitHub

Not much, but it’s a start…

Cool. Should we bump the gradle dependencies for LWJGL3 to 3.2.3? since the arm support was just recently added.

There’s an open issue for that: LWJGL v3.2.2 · Issue #1090 · jMonkeyEngine/jmonkeyengine · GitHub

Would need to test on all major platforms before bumping the version.

Sorry for reviving the dead, but I’ve just ordered a 4b. Does JME function on these devices now?

I am able to run jme in raspberry pi. BUT you need to add a dependency on the lwjgl natives for arm (assuming you are using lwjgl). Also, it will run in OpenGL, not on Open GLES. so it runs kind of slow if you are loading big stuff.

4 Likes

Thanks - I had a read through the thread so I’ll give it a whirl.

Hi @superjugy ,

What did you do exactly to use lwjgl with jme supporting openGL ?

Could I use this :
implementation ‘org.lwjgl:lwjgl-opengl:3.2.3’(but this wonot include other open source java libraries !?)

OR

This :
implementation “org.jmonkeyengine:jme3-lwjgl3:3.3.2-stable”

Or both of them , if you can , please share your Gradle file

You need org.jmonkeyengine:jme3-lwjgl3:3.3.2-stable to actually get jmonkey to use lwjgl. But that will only download the main .so files. ARM binaries are not included by default. so you need to add specifically the ARM binaries.

My build.gradle is a bit messy because I am including 32 bits windows and both 32 and 64 bits ARM. plus I am adding binaries for a lot of dependencies:

  runtimeOnly(rootProject.ext["lwjgl-x86"].toString())
  runtimeOnly(rootProject.ext["lwjgl-arm32"].toString())
  runtimeOnly(rootProject.ext["lwjgl-arm64"].toString())
  runtimeOnly(rootProject.ext["lwjgl-glfw-x86"].toString())
  runtimeOnly(rootProject.ext["lwjgl-glfw-arm32"].toString())
  runtimeOnly(rootProject.ext["lwjgl-glfw-arm64"].toString())
  runtimeOnly(rootProject.ext["lwjgl-jemalloc-x86"].toString())
  runtimeOnly(rootProject.ext["lwjgl-jemalloc-arm32"].toString())
  runtimeOnly(rootProject.ext["lwjgl-jemalloc-arm64"].toString())
  runtimeOnly(rootProject.ext["lwjgl-openal-x86"].toString())
  runtimeOnly(rootProject.ext["lwjgl-openal-arm32"].toString())
  runtimeOnly(rootProject.ext["lwjgl-openal-arm64"].toString())
  runtimeOnly(rootProject.ext["lwjgl-opengl-x86"].toString())
  runtimeOnly(rootProject.ext["lwjgl-opengl-arm32"].toString())
  runtimeOnly(rootProject.ext["lwjgl-opengl-arm64"].toString())

where for example rootProject.ext[“lwjgl-arm64”].toString() is equal to “org.lwjgl:lwjgl:3.2.3:natives-linux-arm64” and so on.

Keep in mind though that you will only be able to use OpenGL, NOT OpenGL ES. I really hope JMonkeyEngine added support for OpenGL ES in their desktop library and not only their android library. I would assume it will speed things up quite a bit in RPi, but I wouldn’t know.

2 Likes

Thanks @superjugy :slightly_smiling_face::heart::+1:

1 Like

Hi @superjugy ,

Have you tried controlling GPIO pins using PI4j or j2ME on RPI4 B ? , Because I found RPI forums are not very helpful regarding java developers .

Thanks

Sorry, I have never tried it. My guess is that the easiest way would be to not do it with Java. do it is C and then just wrap a native call from java or something. But I wouldn’t know, never tried it.

1 Like

I found this library: GitHub - mattjlewis/pigpioj: Java JNI wrapper around the pigpio C library which is a JNI wrapper around the pigpio C library. Have you seen this one?. There is also: GitHub - mattjlewis/diozero: Java Device I/O library that is portable across Single Board Computers. Tested with Raspberry Pi, Odroid C2, BeagleBone Black, Next Thing CHIP, Asus Tinker Board and Arduinos. Supports GPIO, I2C, SPI as well as Serial communication. Also known to work with Udoo Quad. and GitHub - nkolban/jpigpio: A Java interface to the Raspberry Pi pigpio library.

1 Like

No those are new to me !

This is the pi4J :

& I have found this book that seems to be using PI4j , j2ME , seems to be an official one :
raspberry-pi-with-java-programming-the-internet-of-things-iot-oracle-press

Anyway , let’s not be too much outside of jme here , I will try Pi4J & j2ME & see if things work.

Thanks , @superjugy

1 Like

Hello @superjugy , just to know , i bought RPI4B , but JmE didnot work even if implementing the 3.2.3lwjgl for arm64 Jme desktop ignores it & searches for its own library on org.jmonkeyEngine.lwjgl ,

so it gives a UnSatisfiedLinkError.openal not supported by Linux-arm64 if using jmeLwjgl

& if using the lwjgl3.2.3 linux arm64 it gives me ClassNotFoundException jme cannot find lwjgl desktop
do you have a solution for this?

as regards Pi4J if you want to know , i have tried it & its working , basically its based on WiringPI C lang library ,so you have to use WiringPI Strategy of wiring pins :slight_smile:

EDIT : Discovered that wiring Pi datasheet of RPI4b would be the same as RPI3B since they have the same number of pins , you can find these data on Pi4J official website

Can you paste your build.gradle? Also, have you updated your rpi4 to the latest?

1 Like

Hi @superjugy , sorry for late reply , i rarely open my RPI these days of exams :sweat_smile: , i have the latest Raspibian installed , what do you mean by update , you mean update through apt packages ? or the system update ?

This is my gradle file :

plugins {
    id 'java'
}

group 'com.Scrappers'
version '1.0'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    implementation "com.pi4j:pi4j-core:1.2" 
    
    implementation "org.lwjgl:lwjgl:3.2.3:natives-linux-arm64"
    implementation "org.jmonkeyengine:jme3-core:3.3.2-stable"
    implementation "org.jmonkeyengine:jme3-desktop:3.3.2-stable"
    
}

currently this gives me this error :

> Task :JmETest.main()
Dec 31, 2020 3:33:24 AM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.3.2-stable
 * Branch: HEAD
 * Git Hash: 1a05e3f
 * Build Date: 2020-04-27
Dec 31, 2020 3:33:25 AM com.jme3.system.JmeDesktopSystem newContextLwjgl
SEVERE: CRITICAL ERROR: Context class is missing!
Make sure jme3_lwjgl-ogl is on the classpath.
java.lang.ClassNotFoundException: com.jme3.system.lwjgl.LwjglDisplay
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:315)
	at com.jme3.system.JmeDesktopSystem.newContextLwjgl(JmeDesktopSystem.java:199)
	at com.jme3.system.JmeDesktopSystem.newContext(JmeDesktopSystem.java:279)
	at com.jme3.system.JmeSystem.newContext(JmeSystem.java:159)
	at com.jme3.app.LegacyApplication.start(LegacyApplication.java:461)
	at com.jme3.app.LegacyApplication.start(LegacyApplication.java:424)
	at com.jme3.app.SimpleApplication.start(SimpleApplication.java:127)
	at JmETest.main(JmETest.java:10)

Exception in thread "main" java.lang.NullPointerException
	at com.jme3.system.JmeDesktopSystem.newContext(JmeDesktopSystem.java:280)
	at com.jme3.system.JmeSystem.newContext(JmeSystem.java:159)
	at com.jme3.app.LegacyApplication.start(LegacyApplication.java:461)
	at com.jme3.app.LegacyApplication.start(LegacyApplication.java:424)
	at com.jme3.app.SimpleApplication.start(SimpleApplication.java:127)
	at JmETest.main(JmETest.java:10)

> Task :JmETest.main() FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':JmETest.main()'.
> Process 'command '/usr/lib/jvm/java-11-openjdk-armhf/bin/java'' finished with non-zero exit value 1

which is mainly due to lwjgl:display class inside lwjgl of jme that only supports the desktop amd no arm support

Thanks

Hey @Pavl_G,

In your build.gradle I only see you adding the natives for lwjgl. try also adding the natives for lwjgl-glfw, lwjgl-jemalloc, lwjgl-opengl and lwjgl-openal. maybe that will fix it.

As for update, yes, I meant a sudo apt upgrade or sudo apt update

1 Like

Are there any other modules , that must be added also rather than these ?

Those are the only ones I have.

1 Like