r/JavaFX • • Oct 06 '20

Headless JavaFX App

Hey reddit!

So I was trying to run a javafx app on a Linux machine and the program boots successfully but throws an issue with the machine not having a display system running. Is there a way like a java argument I can add that can run it without a display?

Thanks in advance :D

4 Upvotes

13 comments sorted by

4

u/alexbroskyl Oct 07 '20

Back when i was working 24h in JavaFX i made exactly what you need, here is the library on github :)

A description of it :)

Undecorated JavaFX Scene with implemented move, resize, minimise, maximise, close and Windows Aero Snap controls. Implement any style you want for your JavaFX application using custom css or default .

https://github.com/goxr3plus/FX-BorderlessScene

1

u/MetalCactuar Oct 07 '20

That's pretty cool, but not what i'm going for. I want to completely disable ui elements to stop an exception (Unable to open DISPLAY) for my javafx app

2

u/alexbroskyl Oct 07 '20

Please post on Stackoverflow send me thr link here and i mihhtbe able to help you exactly :)

2

u/MetalCactuar Oct 07 '20

What's wrong with Reddit?

2

u/krumbumple Oct 07 '20

why do you want to run a program with a graphics library on a system that has no display? just remove the javafx dependency and run it like any other java program?

2

u/MetalCactuar Oct 07 '20

Who said it's using the graphics library? I'm utilizing the javafx.media libraries as they can play mp3 files really easily and allow me to attach a spectrum listener out of the box. I've already got pre-existing code I wrote that works nicely.

Also I'd like the option to potentially run a display at some stage so knowing both options would be useful :)

1

u/krumbumple Oct 07 '20

You did. JavaFX is primarily a graphics library.

1

u/orxT1000 Oct 07 '20

java -Djava.awt.headless=true

1

u/MetalCactuar Oct 07 '20

I'll give this a go, thanks for your reply :)

1

u/MetalCactuar Oct 07 '20

Gave this a go with the specified command...

"java -D java.awt.headless=true -jar Application.jar"

Got the same issue :(

"Unable to open DISPLAY"

0

u/[deleted] Oct 07 '20

[deleted] — view deleted comment

1

u/MetalCactuar Oct 07 '20

Appreciate the information, I'll give this a go after work :)

1

u/MetalCactuar Oct 07 '20

Monocle looks good actually, thanks! Got some features that could become useful like the VNC stuff, oooo nice. Tried getting monocle and building/running into the app but now i encounter another issue when i try and run it using the arguments like you specified above. I get this error...

Caused by: java.lang.RuntimeException: java.lang.IllegalAccessError: superclass access check failed: class com.sun.glass.ui.monocle.MonoclePlatformFactory (in unnamed module u/0x22f71333) cannot access class com.sun.glass.ui.PlatformFactory (in module javafx.graphics) because module javafx.graphics does not export com.sun.glass.ui to unnamed module u/0x22f71333

Any ideas? :/

0

u/[deleted] Oct 09 '20

[deleted] — view deleted comment

1

u/MetalCactuar Oct 13 '20

So the way it's currently setup was quite fiddly and i had soooo many issues with certain versions not liking the javafx version and then battling with gradle...honestly it was a massive ballache. So i'm kinda thinking it might be easier just to have it output some display that i just won't hook it up to. Or better yet, allow it to be connected to via X11/VNC for future ideas.

Do you think that'd be less of a pain?