awvalenti / bauhinia

Cross-platform Wii Remote Java library and remote controller application
GNU General Public License v3.0
6 stars 0 forks source link

nitida doesn´t work with a JRE #15

Closed jabrena closed 7 years ago

jabrena commented 7 years ago

Hi,

I am testing the development in a embedded environment, but the device only have a JRE, the software doesn´t work.

robot@ev3dev:~$ java -jar nitida-0.1.0.jar --console
nitida  Copyright (C) 2015  Andre Willik Valenti
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions.
Licensed under GPLv3.  For more information, please visit:
  http://www.gnu.org/licenses/gpl-3.0.en.html
For source code and project information, please visit:
  https://github.com/awvalenti/bauhinia

Exception in thread "main" java.lang.RuntimeException: java.awt.AWTException: headless environment
    at com.github.awvalenti.bauhinia.nitida.model.NitidaModel.<init>(NitidaModel.java:24)
    at com.github.awvalenti.bauhinia.nitida.NitidaMain.runNitidaConsole(NitidaMain.java:69)
    at com.github.awvalenti.bauhinia.nitida.NitidaMain.main(NitidaMain.java:29)
Caused by: java.awt.AWTException: headless environment
    at java.awt.Robot.<init>(Robot.java:94)
    at com.github.awvalenti.bauhinia.nitida.model.NitidaModel.<init>(NitidaModel.java:22)
    ... 2 more
awvalenti commented 7 years ago

Hello, jabrena, thanks for submitting your issue!

Apparently, this is not caused by the JRE, but by the fact that java.awt.Robot (the keyboard events generator) needs a graphical environment to be created.

I've searched for a solution and this might solve the problem: java -Djava.awt.headless=false -jar nitida-0.1.0.jar --console

Please try it and tell me if it worked.

jabrena commented 7 years ago

Hi @awvalenti, this week I will test again.

I would like to use the project in combination with: https://github.com/ev3dev-lang-java/ev3dev-lang-java

Cheers

Juan Antonio

jabrena commented 7 years ago

Hi,

I tested but the runtime problem continues:

robot@ev3dev:~$ java -Djava.awt.headless=false -jar nitida-0.1.0.jar --console
nitida  Copyright (C) 2015  Andre Willik Valenti
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions.
Licensed under GPLv3.  For more information, please visit:
  http://www.gnu.org/licenses/gpl-3.0.en.html
For source code and project information, please visit:
  https://github.com/awvalenti/bauhinia

Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /opt/ejdk1.8.0/linux_arm_sflt/jre/lib/arm/libawt_xawt.so
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1817)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1083)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1835)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1119)
    at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:77)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:74)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:259)
    at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:102)
    at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:81)
    at java.awt.Robot.<init>(Robot.java:96)
    at com.github.awvalenti.bauhinia.nitida.model.NitidaModel.<init>(NitidaModel.java:22)
    at com.github.awvalenti.bauhinia.nitida.NitidaMain.runNitidaConsole(NitidaMain.java:69)
    at com.github.awvalenti.bauhinia.nitida.NitidaMain.main(NitidaMain.java:29)

Exist some easy way to have a console version of nitida?

Cheers

Juan Antonio

awvalenti commented 7 years ago

A nice use case! From what I understood, you want to generate keyboard input using a Wii Remote (which is exactly what nitida does), and you want to do that on a Raspberry Pi. If that is not the case and you just want a Wii Remote library to program stuff, coronata is what you are looking for. Probably you'd still run into trouble with the .so files included in coronata, because they were targeted at Intel x86 and x64 architectures.

The last error message you have posted seems to indicate that java.awt.Robot really depends on an AWT graphical environment, which apparently is not present in your scenario.

nitida is in fact able to run in console mode, but unfortunately it depends on a graphical environment to run (I didn't know that before reading your issue...). You might want to look for some substitute for java.awt.Robot that doesn't.

I suggest that you look for that substitute and do some tests. If you find that it works, we could incorporate that change into nitida, so that it automatically chooses the underlying keyboard generating library.

awvalenti commented 7 years ago

I've created more specific issues to replace this one: #16 and #17.

jabrena commented 7 years ago

Hi @awvalenti,

many thanks. I will continue researching on this area. If you find some basic solution, I could test without any problem.

Cheers

Juan Antonio