Error when running javafx app

I am trying to set up a simple javafx window in intellij community edition and i ran into an error. Error: JavaFX runtime components are missing, and are required to run this application What runtime components is it talking about?
163 Replies
JavaBot
JavaBot9mo ago
This post has been reserved for your question.
Hey @DevLop games! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
dan1st
dan1st9mo ago
JavaFX needs some native code and that failed to load You probably want to have a module-info.java in your project
DevLop games
DevLop gamesOP9mo ago
why?
dan1st
dan1st9mo ago
with a content similar to
module yourmodulenamehere {
requires javafx.graphics;
requires javafx.controls;
requires javafx.fxml;//in case you want to use FXML
}
module yourmodulenamehere {
requires javafx.graphics;
requires javafx.controls;
requires javafx.fxml;//in case you want to use FXML
}
because that tells Java what your application needs to run and make sure that's loaded
DevLop games
DevLop gamesOP9mo ago
Can't i just import that?
dan1st
dan1st9mo ago
it's also possible to use --add-modules instead but then you need to specify that every time when compiling or running the application ? it's just an additional file in your source folder, you create a file called module-info.java with that content ofc with a different module name
DevLop games
DevLop gamesOP9mo ago
but what does it need exactly?
dan1st
dan1st9mo ago
?
DevLop games
DevLop gamesOP9mo ago
javafx
dan1st
dan1st9mo ago
native code
DevLop games
DevLop gamesOP9mo ago
what does it need to run a simple window
dan1st
dan1st9mo ago
GUIs are OS-specific
DevLop games
DevLop gamesOP9mo ago
That tells me nothing
dan1st
dan1st9mo ago
so it needs OS-specific (non-Java) code to work and that OS specific code is what's meant with runtime components
DevLop games
DevLop gamesOP9mo ago
Like specific to the the machine it's running on?
dan1st
dan1st9mo ago
yes
DevLop games
DevLop gamesOP9mo ago
Can it run on any os? I just need windows, mac, ios and android.
dan1st
dan1st9mo ago
Windows, MacOS and Linux works - but you need different runtime components Android and iOS are special cases
DevLop games
DevLop gamesOP9mo ago
wdym
dan1st
dan1st9mo ago
GUI code written for Desktop doesn't work on mobile devices. In principle, it's possible to write Android/iOS apps with JavaFX but that's annoying and for some reason you generally can't write any iOS apps without a Macbook for some reason I think (not specific to JavaFX)
DevLop games
DevLop gamesOP9mo ago
So how am i supposed to build for a different os other than my own?
dan1st
dan1st9mo ago
It is possible to include the runtime components for Windows when building on Linux etc (but ofc then you can only run that build on Windows) or you could build a single application containing the runtime components for Windows, MacOS and Linux but that results in having an unnecessarily big application
DevLop games
DevLop gamesOP9mo ago
I could just duplicate and change what i need, but i still need to know if there is a less frustrating way of building for multiple platforms.
dan1st
dan1st9mo ago
(this doesn't work for Android/iOS) less frustrating in what way? it depends on what exactly you want the result to be also I don't know your current way of building
DevLop games
DevLop gamesOP9mo ago
What? I just need to build for different multiple os. Idek how to build in intellij
dan1st
dan1st9mo ago
How? Is it a Maven project?
DevLop games
DevLop gamesOP9mo ago
No
dan1st
dan1st9mo ago
Gradle?
DevLop games
DevLop gamesOP9mo ago
Idk
dan1st
dan1st9mo ago
Do you have a pom.xml, build.gradle or build.gradle.kts file?
DevLop games
DevLop gamesOP9mo ago
Nothing here gradle related
dan1st
dan1st9mo ago
Is there a pom.xml file?
DevLop games
DevLop gamesOP9mo ago
no
dan1st
dan1st9mo ago
So you created a plain IntelliJ project without any build tool That might make some stuff complicated
DevLop games
DevLop gamesOP9mo ago
How?
dan1st
dan1st9mo ago
How do you want users to run your application?
DevLop games
DevLop gamesOP9mo ago
What application. It's a blank project..
dan1st
dan1st9mo ago
Well you have a main method, right?
DevLop games
DevLop gamesOP9mo ago
yes
dan1st
dan1st9mo ago
yeah that's enough for me to call it application xd Can you successfully run the application from IntelliJ?
DevLop games
DevLop gamesOP9mo ago
Yes but how does this help with figuring out what to do when i need to build to another os?
dan1st
dan1st9mo ago
if you build it on the same OS as you run it, that shouldn't be a problem As long as you download JavaFX for that OS
DevLop games
DevLop gamesOP9mo ago
Who is gonna hold onto a dozen devices to build? That's dumb And also unmanagable
dan1st
dan1st9mo ago
That isn't necessary at least not with Maven (or Gradle)
DevLop games
DevLop gamesOP9mo ago
Then how do i build for any os from windows?
dan1st
dan1st9mo ago
1. Set up a Maven project, not a blank IntelliJ project 2. Add JavaFX and make sure it works when you build on Winfows for Windows 3. Decide on how you want to package it (depending on how you want to package it, you might need to build on the platform you are targeting, e.g. MacOS if you want a dmg file) 4. Add the configuration for what you decided on in 3. 5. add the classifier for the platform you want to build (e.g. you add linux to the pom.xml file at the right place if you want to build for Linux) 6. run the command for building Step 3 is the most important one
DevLop games
DevLop gamesOP9mo ago
why do i need a mac computer just to build for mac?
dan1st
dan1st9mo ago
I typically use GitHub actions to run the build on multiple platforms so I don't need devices matching all platforms but that's complicated to set up. It depends. If you want to build a dmg file (which is like .exe but for Mac), that thing is specific to MacOS and the tools dor building that are available on MacOS only AFAIK.
DevLop games
DevLop gamesOP9mo ago
I don't supposed you have an iso on hand?
dan1st
dan1st9mo ago
if you want to build a JAR file, you don't need a MacOS device but for a dmg file, you need MacOS. I don't think Apple makes it easy to use MacOS virtual Machines but that's step 3. in what I mentioned
DevLop games
DevLop gamesOP9mo ago
So if i wanted to build for mac i would need a mac?
dan1st
dan1st9mo ago
Depends What exactly do you want the result to be?
DevLop games
DevLop gamesOP9mo ago
Obviously an executable
dan1st
dan1st9mo ago
Then building needs to be done on MacOS It is possible to do this via GH Actions so you don't need your own MacOS device but that's a bit complicated to set up and you first need a reliable way to build it with a terminal
DevLop games
DevLop gamesOP9mo ago
How complicated we talkin?
dan1st
dan1st9mo ago
First, you need a reliable way to build it from the terminal Then, you need to put your project on GitHub (that part is easy) and then you need to write instructions for GitHub to build the project on whatever platform you like then you need to fix any problems caused by that
DevLop games
DevLop gamesOP9mo ago
Problems?
dan1st
dan1st9mo ago
In my experience, it doesn't work on the first attempt.
DevLop games
DevLop gamesOP9mo ago
Why is that?
dan1st
dan1st9mo ago
because these steps are complicated enough that it's very easy to make mistakes in a lot of places Linux is typically easy (unless you put Windows specific things there), Windows has the issue that it's completely different but ideally you don't do anything specific to ywindows and it's fine and for MacOS - you wouldn't be the first one that doesn't realize the application doesn't work at all on MacOS for months until some MacOS user tries to use it.
DevLop games
DevLop gamesOP9mo ago
Is it even possible to get an application going for mac os with this?
dan1st
dan1st9mo ago
yes I also did it at some point but I don't have a MacOS device so I have no way of knowing whether it worked (but tbh I don't care about Apple users much)
DevLop games
DevLop gamesOP9mo ago
Android person?
dan1st
dan1st9mo ago
for mobiles yes But if you want it to run on mobile devices, that's more complicated than desktop
DevLop games
DevLop gamesOP9mo ago
What's more complicated than android?
dan1st
dan1st9mo ago
and if you want to write an application for iOS, you actually need a MacOS device to create it - because Apple mandates it
DevLop games
DevLop gamesOP9mo ago
That sucks
dan1st
dan1st9mo ago
Mobile devices are inherently different from normal computers. Desktop applications generally don't work on Android/iOS. While JavaFX should somewhat work on these, that will cause a lot of issues along the way and you'll probably not be able to use a lot of stuff that you might otherwise be able to use (some things don't exist on mobile devices, some are restricted, some require special permissions, some may not be supported by JavaFX).
DevLop games
DevLop gamesOP9mo ago
Bruh this is getting me nowhere. It's always some issue forcing me in different directions.
dan1st
dan1st9mo ago
Why do you think people are writing either Desktop or mobile applications or two different applications (one for Desktop and one for mobile)?
DevLop games
DevLop gamesOP9mo ago
Uhm for the executables..
dan1st
dan1st9mo ago
There isn't even a concept of executables on mobiles well technically there is but the user doesn't see it
DevLop games
DevLop gamesOP9mo ago
Technically the code is being executed when the app is ran soo
dan1st
dan1st9mo ago
yeah but you need to install the app which os an entirely different process
DevLop games
DevLop gamesOP9mo ago
Not the point. Is there a library where both desktop and mobile devices have full support?
dan1st
dan1st9mo ago
I think these libraries exist but that doesn't change that you need a Mac when building for iOS
DevLop games
DevLop gamesOP9mo ago
That still sucks
dan1st
dan1st9mo ago
I have seen people writing JavaFX applications for mobile devices in experimental settings but never for actually interesting apps and I never tried myself so I don't know what exactly (doesn't) work
DevLop games
DevLop gamesOP9mo ago
Then i need a library that will work well on mobile
dan1st
dan1st9mo ago
But mobile devices are very restrictive, you normally don't have a keyboard/mouse and the screen is different- that's where the problems start
DevLop games
DevLop gamesOP9mo ago
Why yhe hell would a mobile device need a keyboard?
dan1st
dan1st9mo ago
or you write the application once for Desktop and once for mobile Because most applications are written for keyboard/mouse
DevLop games
DevLop gamesOP9mo ago
Which are portable to mobile
dan1st
dan1st9mo ago
and if you rely on that, you might have difficulties with mobile devices
DevLop games
DevLop gamesOP9mo ago
Why would i need a keyboard and mouse for mobile
dan1st
dan1st9mo ago
As I said, Desktop applications are often written for users with a mouse and keyboard while mobile applications are typically written for touchscreen use
DevLop games
DevLop gamesOP9mo ago
Literally every app does this
dan1st
dan1st9mo ago
people typically design these completely differently exactly and almost every app is one of - only available on Desktop - only available on mobile - written (at least) twice: For mobile and for desktop (often even 3x: For Desktop, for Android and for iOS)
DevLop games
DevLop gamesOP9mo ago
only some
dan1st
dan1st9mo ago
and even with a library that supports both Desktop and mobile devices: one still needs a Mac to build iOS apps most
DevLop games
DevLop gamesOP9mo ago
No I could try a forbidden method
dan1st
dan1st9mo ago
I mean, if an app is essentially a website that's a bit of a different story
DevLop games
DevLop gamesOP9mo ago
You never answered my question
dan1st
dan1st9mo ago
but for apps that aren't websites in disguise (an example of that is Discord which still had 3 completely differently developed apps for a very long time - idk how different they are now), people normally write them multiple times if they want both Desktop and mobile.
DevLop games
DevLop gamesOP9mo ago
Is there a library that offer full mobile support?
dan1st
dan1st9mo ago
I said yes But I don't know these libraries And I also said that JavaFX does support both mobile and Desktop but I don't know how well it works I do know about LibGdX but that's a game library/framework lol and that's still a thing
DevLop games
DevLop gamesOP9mo ago
Why do you keep mentiioning it I haven't said anything about mac since the last few replies
dan1st
dan1st9mo ago
because building for MacOS seemed important for you
DevLop games
DevLop gamesOP9mo ago
Hell naw if anything i'm siding with android bc google is alot nicer with their pricing 💀
dan1st
dan1st9mo ago
lol oh and if you want to publish an Android app, you probably want to use the Play Store, right? If so, that's "fun" as well, just warning you
DevLop games
DevLop gamesOP9mo ago
Eh ?
dan1st
dan1st9mo ago
It requires - paying a small one-time fee via credit/debit card when creating the account (I guess that's for identity verification and/or prevents being flooded with apps that do nothing) - there are a few weird forms (but nothing too bad IIRC) - they may randomly remove your app after it's already published when they decide it violates their guidelines (e.g. if they don't like the name of your app or your username) - they might reject your app if it doesn't start
DevLop games
DevLop gamesOP9mo ago
Thats what i meant by nicer
dan1st
dan1st9mo ago
?
DevLop games
DevLop gamesOP9mo ago
Wait they can remove my app for no reason?
dan1st
dan1st9mo ago
well the reason being it violating their guidelines
DevLop games
DevLop gamesOP9mo ago
What about friendly names?
dan1st
dan1st9mo ago
but my username being "dan1st" was enough for that username, not app name
DevLop games
DevLop gamesOP9mo ago
Oh They remove apps over usernames for no reason?
dan1st
dan1st9mo ago
it's not no reason
DevLop games
DevLop gamesOP9mo ago
so how can dan1st get an app removed?
dan1st
dan1st9mo ago
They don't want any apps with things like "#1", "first" etc and apparently this is also the case for usernames
DevLop games
DevLop gamesOP9mo ago
That's dumb That's youtube moderation ts
dan1st
dan1st9mo ago
idk their guidelines are too confusing for me
DevLop games
DevLop gamesOP9mo ago
Good thing my target isn't the app store
dan1st
dan1st9mo ago
I don't have an issue with YT moderation. but it is the same company
DevLop games
DevLop gamesOP9mo ago
You're not a youtuber so ofc you wouldn't
dan1st
dan1st9mo ago
lucky you Actually, what's your definition of that?
DevLop games
DevLop gamesOP9mo ago
I seen quite a few cases and heard a ton of stories of how youtube moderation is and it's pretty dumb
dan1st
dan1st9mo ago
I know about that but it isn't YT being bad tbh
DevLop games
DevLop gamesOP9mo ago
False moderation is bad
dan1st
dan1st9mo ago
DMCA isn't YT's invention if you are talking about that - and Google is forced to take it down even if they cannot verify it being a copyright infringement
DevLop games
DevLop gamesOP9mo ago
So you're telling me someone can make a false report and google have to follow it?
dan1st
dan1st9mo ago
That's for every US website with user generated content. If it isn't removed, the website owner is responsible for the content. But sending false DMCA takedowns is illegal and when writing a takedown request, you have to include personal information and idk what else IIRC.
DevLop games
DevLop gamesOP9mo ago
There was something on the platform that was abusable
dan1st
dan1st9mo ago
that's with many platforms - I don't doubt that and I think I know what you are talking about
DevLop games
DevLop gamesOP9mo ago
Was it the report button?
dan1st
dan1st9mo ago
I think not but there are multiple things and content moderation on that scale is really hard
DevLop games
DevLop gamesOP9mo ago
Why not have auto mod scan content as soon as a video is uploaded
dan1st
dan1st9mo ago
it isn't enough though I am not really here to talk about the reasons for that
DevLop games
DevLop gamesOP9mo ago
Same this went a little off topic. Back to the current issue and ofc building. Wait if i need to build i need to add a build system when creating a project?
dan1st
dan1st9mo ago
I would recommend doing so
DevLop games
DevLop gamesOP9mo ago
Even if i don't need it atm? Probably a dumb question
dan1st
dan1st9mo ago
With a build tool, you can have reliable builds from a terminal, independently of OS and IDE
DevLop games
DevLop gamesOP9mo ago
Which build system works for both windows and linux?
dan1st
dan1st9mo ago
https://discord.com/channels/648956210850299986/1130182060410159144 For Java, both Maven and Gradle work and these aren't OS dependent
DevLop games
DevLop gamesOP9mo ago
So i could run this on windows an linux no problem? What is gradle dsl?
dan1st
dan1st9mo ago
the build tool doesn't care about the OS. But if you build something for one OS, it won't work on another.
DevLop games
DevLop gamesOP9mo ago
Unless i build on that os?
dan1st
dan1st9mo ago
the language Gradle uses for configurating the build
DevLop games
DevLop gamesOP9mo ago
leave it default right?
dan1st
dan1st9mo ago
if you build a native Windows executable (exe, msi, etc), you can probably only do it on Windows and the executable will probably only run on Windows. but if you build a JAR, thag should be possible in a way that it runs on Windows, MacOS and Linux (but that JAR would be big) should be fine
DevLop games
DevLop gamesOP9mo ago
But if i use the linux sub system then..
dan1st
dan1st9mo ago
then you can probably also run Linux applications
DevLop games
DevLop gamesOP9mo ago
Oh so then i don't have to worry about those two os
dan1st
dan1st9mo ago
though I think if you use WSL on Win10, that doesn't work with GUI applications
DevLop games
DevLop gamesOP9mo ago
what is that?
dan1st
dan1st9mo ago
if you build JARs and not native executables/installers, you can build it on whatever platform you like WSL? or GUI?
DevLop games
DevLop gamesOP9mo ago
wsl
dan1st
dan1st9mo ago
Windows subsystem for Linux
DevLop games
DevLop gamesOP9mo ago
Also btw i need executables for those os
dan1st
dan1st9mo ago
it's just the abbreviation
DevLop games
DevLop gamesOP9mo ago
oh short version
dan1st
dan1st9mo ago
Are installers ok?
DevLop games
DevLop gamesOP9mo ago
I mean ig but how does that relate to me getting an executable for windows and linux?
dan1st
dan1st9mo ago
Installers are annoying enough, actual executables that don't require an installation process are even harder If you have an installer, you need to install it before using e.g. on Linux (at least on Ubuntu), you could do that with sudo apt install ./yourapp.deb
DevLop games
DevLop gamesOP9mo ago
How so?
dan1st
dan1st9mo ago
Java applications typically require a Java installation. The installer would ensure both is available. There is another way but that comes with some limitations and it isn't beginner-friendly well the first way isn't that beginner-friendly as well Here is roughly how it works: https://discord.com/channels/648956210850299986/1254481100525273111 (That description is without a build tool)
DevLop games
DevLop gamesOP9mo ago
why do java apps need an installer?
dan1st
dan1st9mo ago
because Java needs to be installed and the installer installs Java, JavaFX and the application at least if configured correctly
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
dan1st
dan1st9mo ago
that is the thing I mentioned before but idk how well this works and it's probably painful
JavaBot
JavaBot9mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?