4

I am trying to run my JavaFX program (Aiish_GUI.jar) on Raspberry Pi 3 B+, And I get an error which looks like this:

When i run command with sudo: When i run command with sudo

When i run command without sudo When i run command without sudo

As can be seen in the first image, my JavaFX project includes exteral library jar files(Apache POI to read and write excel files)

The project was done in IntelliJ IDE and artifacts created from the same. It works as Expected in Windows 10 and Ubuntu 16.04 but i get these problems on Raspbian

Extra details

  • I have Installed openjdk 8 jdk and jre
  • And done this--> How can i get JavaFX working on raspberry pi 3
  • I am totally new to Raspberry Pi as well as Raspbian OS. Hope i can get my program running soon. Thanks in advance :)

    Martin
    • 2,411
    • 11
    • 28
    • 30
    Vrushank V
    • 41
    • 5
    • Have you tried running the app without X Windows? Just logout to the shell, and run it there again. – José Pereda Jun 30 '18 at 13:55
    • Thanks for the reply @JoséPereda! I am new to Raspberry Pi.. Hence I don't know how to logout to the shell. Please let me know :) Thank you – Vrushank V Jun 30 '18 at 20:23
    • You can logout from the program menu, and then click exit to command line. – José Pereda Jun 30 '18 at 20:45
    • Thanks for the reply again! :D I tried running from the command line.. And got the same error-> https://imgur.com/a/spz6KsM . :( .. My code and jar files are available here -> https://github.com/VrushankV/Localization-GUI-AIISH . – Vrushank V Jul 01 '18 at 06:14
    • Maybe you can try now a simple project just to test that your setup (OpenJDK + JavaFX) is correct? – José Pereda Jul 01 '18 at 09:04
    • I tried running a program which has a click me button in the stage.. It gave me the same error (Cannot open display cannot create resource). I did gksudo -u pi and tried to run java -jar Aiish_GUI.jar Still the same.. I reinstalled openjdk through -- sudo apt-get install -y galternatives openjdk-8-jdk and javafx through -- sudo apt-get-install openjfx ... and it's still the same :( (by the way normal java programs run fine , ones without javafx) – Vrushank V Jul 01 '18 at 16:42
    • I'd suggest installing Oracle JDK 8 for ARM, that will also require JavaFX for ARM. Make sure you install everything properly. – José Pereda Jul 01 '18 at 16:45
    • Thank you @JoséPereda. What I've done till now.. 1)Followed this -->https://www.youtube.com/watch?v=rrwRSAU_ZgI ..2)Followed your answer here -->https://stackoverflow.com/questions/38102348/javafx-on-arm-running-jdk1-8-0 .... Now, when i run without sudo getting the same errors--> https://imgur.com/a/5F88fp4 and when i run it using gksudo -u pi Screen hangs like this ->https://imgur.com/a/fZr0W4z – Vrushank V Jul 01 '18 at 19:28
    • Why do you use `gksudo`? Use `sudo java -jar ...`. And you should run from the shell, not from X Windows – José Pereda Jul 01 '18 at 20:08
    • I tried running it from the shell and the system hangs.. and gives the screen similar to the second attached image of my previous comment.. There is no mouse pointer.. only button that works then is space bar pressing which i get a screen like (The screen goes after the space bar release hence the picture is not clear,sorry)--> https://imgur.com/a/p3y24Bn – Vrushank V Jul 02 '18 at 09:37
    • I see an `UnsupportedOperationException` on top. Weren't you trying a simple JavaFX project? – José Pereda Jul 02 '18 at 09:46
    • When I ran a simple program(with a button on a window saying click me), the screen hangs completely.. there was no change in the screen on pressing space bar.. how it looked--->https://imgur.com/a/5XuLDRL – Vrushank V Jul 02 '18 at 13:43

    2 Answers2

    1

    Add this code before anything else in your terminal DISPLAY=:0 your program path and execute here

    Uchiha
    • 11
    • 2
    0

    To solve needing sudo--

    edit /etc/udev/rules.d/99-com.rules

    And paste this script at the bottom of the file:

    SUBSYSTEM=="input*", PROGRAM="/bin/sh -c '\
    chown -R root:input /sys/class/input/*/ && chmod -R 770 /sys/class/input/*/;\
    '"
    

    Stolen from: https://alexconesa.wordpress.com/2017/08/14/udev-failed-to-write-to-sysclassinputmiceuevent-check-that-you-have-permission-to-access-input-devices-on-raspberry-pi/

    The other problem is Java's way of falling flat on it's face, often due to a bug. You are probably going to have to get it to write out a core dump before you can even get started (Check to see if the referenced core dump actually got written, it looks like it failed)

    Bill K
    • 62,186
    • 18
    • 105
    • 157