jonny789
Posts: 43
Joined: Tue May 14, 2013 2:34 pm
Location: Near My Raspberry Pi

JavaFX: Cannot open display problem

Sat Dec 23, 2017 8:56 am

I want to create some GUI for Raspberry Pi 1 B. So I found JavaFX is best for my purpose. Installed it following this tutorial :
http://www.oracle.com/webfolder/technet ... rryfx.html

Created Basic JavaFX Application-Hello World. Set GPU memory to 128M.
Copied BasicFX.jar to pi and ran using ::

Code: Select all

sudo java -jar BasicFX.jar 
. But it showed this

Code: Select all

error ::  error: could not find or load main class java
After searching for solution , I found this : stackoverflow.com/questions/38359076/h ... berry-pi-3 . But Running it again showing this error now ::

Code: Select all

Cannot open display
Exception in Application start method
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
        at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$156(LauncherImpl.java:182)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ExceptionInInitializerError
        at javafx.scene.Node.reapplyCss(Node.java:8983)
        at javafx.scene.Node.impl_reapplyCSS(Node.java:8946)
        at javafx.scene.Node.invalidatedScenes(Node.java:854)
        at javafx.scene.Node.setScenes(Node.java:919)
        at javafx.scene.Scene$9.invalidated(Scene.java:1119)
        at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111)
        at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
        at javafx.scene.Scene.setRoot(Scene.java:1072)
        at javafx.scene.Scene.<init>(Scene.java:347)
        at javafx.scene.Scene.<init>(Scene.java:223)
        at basicfx.BasicFX.start(BasicFX.java:37)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(LauncherImpl.java:863)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(PlatformImpl.java:326)
        at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
        at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:93)
        at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:52)
        ... 1 more
Caused by: java.lang.NullPointerException
        at com.sun.javafx.font.PrismFontLoader.loadFont(PrismFontLoader.java:196)
        at javafx.scene.text.Font.<init>(Font.java:319)
        at javafx.scene.text.Font.getDefault(Font.java:86)
        at javafx.scene.CssStyleHelper.<clinit>(CssStyleHelper.java:1528)
        ... 19 more
Exception running application basicfx.BasicFX
Last edited by jonny789 on Sat Dec 23, 2017 9:32 am, edited 1 time in total.

User avatar
DougieLawson
Posts: 33334
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: JavaFX: Cannot open display problem

Sat Dec 23, 2017 9:04 am

1. DON'T use sudo, it shouldn't need sudo. Stop running everything as root.
2. Set the display variable see if that helps.

DISPLAY=:0 java -jar BasicFX.jar
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

jonny789
Posts: 43
Joined: Tue May 14, 2013 2:34 pm
Location: Near My Raspberry Pi

Re: JavaFX: Cannot open display problem

Sat Dec 23, 2017 9:26 am

DougieLawson wrote:
Sat Dec 23, 2017 9:04 am
1. DON'T use sudo, it shouldn't need sudo. Stop running everything as root.
Actually runnning without sudo shows these errors ::

Code: Select all

Udev: Failed to write to /sys/class/input/mice/uevent
      Check that you have permission to access input devices
Udev: Failed to write to /sys/class/input/input1/uevent
      Check that you have permission to access input devices
Udev: Failed to write to /sys/class/input/event1/uevent
      Check that you have permission to access input devices
Udev: Failed to write to /sys/class/input/input2/uevent
      Check that you have permission to access input devices
Udev: Failed to write to /sys/class/input/event2/uevent
      Check that you have permission to access input devices
Udev: Failed to write to /sys/class/input/input0/uevent
      Check that you have permission to access input devices
Udev: Failed to write to /sys/class/input/event0/uevent
      Check that you have permission to access input devices
DougieLawson wrote:
Sat Dec 23, 2017 9:04 am
2. Set the display variable see if that helps.

DISPLAY=:0 java -jar BasicFX.jar
Errors are still the same.


Do I need to do any setting to set output to hdmi ? Anything inside /boot/config.txt ?

User avatar
DougieLawson
Posts: 33334
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: JavaFX: Cannot open display problem

Sat Dec 23, 2017 9:58 am

Is the GUI running? Are you running your Java program in a LXTerminal window?
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

jonny789
Posts: 43
Joined: Tue May 14, 2013 2:34 pm
Location: Near My Raspberry Pi

Re: JavaFX: Cannot open display problem

Sat Dec 23, 2017 11:54 am

DougieLawson wrote:
Sat Dec 23, 2017 9:58 am
Is the GUI running? Are you running your Java program in a LXTerminal window?
There is no GUI. I have installed Raspbian Stretch Lite.

User avatar
DougieLawson
Posts: 33334
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: JavaFX: Cannot open display problem

Sat Dec 23, 2017 3:07 pm

You can't run Java graphics without Xwindows.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

jonny789
Posts: 43
Joined: Tue May 14, 2013 2:34 pm
Location: Near My Raspberry Pi

Re: JavaFX: Cannot open display problem

Sat Dec 23, 2017 3:41 pm

DougieLawson wrote:
Sat Dec 23, 2017 3:07 pm
You can't run Java graphics without Xwindows.
Which package or program do I need to install ?

User avatar
DougieLawson
Posts: 33334
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: JavaFX: Cannot open display problem

Sat Dec 23, 2017 3:45 pm

X11 Xwindows.

sudo apt update
sudo apt install raspberrypi-ui-mods

should pull in what you need.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

jonny789
Posts: 43
Joined: Tue May 14, 2013 2:34 pm
Location: Near My Raspberry Pi

Re: JavaFX: Cannot open display problem

Sat Dec 23, 2017 7:23 pm

DougieLawson wrote:
Sat Dec 23, 2017 3:45 pm
X11 Xwindows.

sudo apt update
sudo apt install raspberrypi-ui-mods

should pull in what you need.
Thanks. It is working now. :)

raspberrypi-ui-mods is quite big (455 MB) for my 2GB card. So there is not enough space to install it. Therefore, I installed just minimal packages (taking about 120MB space) to run JavaFX.

Code: Select all

sudo apt install xorg  libgtk2.0-0
But, I still need to run with sudo, for GUI apps needing mouse and keyboard.
While running , it still shows these messages ::

Code: Select all

Cannot open display
Cannot create resource
But it works fine. ;)

Bhaumik156
Posts: 2
Joined: Fri Feb 02, 2018 10:04 am

Re: JavaFX: Cannot open display problem

Fri Feb 02, 2018 10:08 am

I want to run a javafx software . It is giving me the same errors as mentioned above. I tried the steps above but no results and it is showing the same error cannnot open display and cannot create resource . please help

Bhaumik156
Posts: 2
Joined: Fri Feb 02, 2018 10:04 am

Re: JavaFX: Cannot open display problem

Fri Feb 02, 2018 10:27 am

still error is persisting with my application and it is not running
pleasse help

B.Goode
Posts: 6192
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: JavaFX: Cannot open display problem

Fri Feb 02, 2018 10:35 am

Bhaumik156 wrote:
Fri Feb 02, 2018 10:27 am
still error is persisting with my application and it is not running
pleasse help
Advice in these forums is provided by unpaid volunteers. Maybe noone with the necessary interest, skills or knowledge has logged in during the 19 minutes since you first raised this query.

To improve your chances of a helpful response, indicate what Operating System is running on your RPi, and how its graphical output is configured : a directly connected display with a standard Raspbian Pi Foundation desktop, or a network accessed 'headless' installation?

Which of the steps already suggested to previous posters have you tried, and with what results?

texy
Forum Moderator
Forum Moderator
Posts: 5130
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: JavaFX: Cannot open display problem

Fri Feb 02, 2018 10:57 am

B.Goode wrote:
Fri Feb 02, 2018 10:35 am
Bhaumik156 wrote:
Fri Feb 02, 2018 10:27 am
still error is persisting with my application and it is not running
pleasse help
Advice in these forums is provided by unpaid volunteers. Maybe noone with the necessary interest, skills or knowledge has logged in during the 19 minutes since you first raised this query.

To improve your chances of a helpful response, indicate what Operating System is running on your RPi, and how its graphical output is configured : a directly connected display with a standard Raspbian Pi Foundation desktop, or a network accessed 'headless' installation?

Which of the steps already suggested to previous posters have you tried, and with what results?
What B.Goode said - please be patient.
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

ripcore
Posts: 6
Joined: Mon Jan 22, 2018 3:42 pm

Re: JavaFX: Cannot open display problem

Sun Feb 04, 2018 12:11 pm

Bhaumik156 wrote:
Fri Feb 02, 2018 10:08 am
I want to run a javafx software . It is giving me the same errors as mentioned above. I tried the steps above but no results and it is showing the same error cannnot open display and cannot create resource . please help
What is your OS on pi?
Do you use LCD screen or Touch Screen?

JLamberti
Posts: 1
Joined: Fri Apr 06, 2018 9:50 pm

Re: JavaFX: Cannot open display problem

Fri Apr 13, 2018 1:08 pm

Hi, everybody.

I'm new on Raspberry development. I have the very same problem. The application runs fine, i figure out that if i move the mouse the cursor position on the controls and if i clickit the application runs fine.

For solving the access to the input devices issues i followed this link: https://alexconesa.wordpress.com/2017/0 ... pberry-pi/

But the cursor don't appears.

The thing is this:
I've tried NOOBS and Raspbian with the same jar file, with the same results.

I installed differents JDK8 releases, with the last Gluom JavaFX.

I'm working on a IoT projecr using the RPI. Any help wil be appretiated.

Hope the lilnk was usefull

Return to “Java”

Who is online

Users browsing this forum: No registered users and 5 guests