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
⌛
This post has been reserved for your question.
Hey @DevLop games! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose 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.
JavaFX needs some native code and that failed to load
You probably want to have a module-info.java in your project
why?
with a content similar to
because that tells Java what your application needs to run and make sure that's loaded
Can't i just import that?
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 namebut what does it need exactly?
?
javafx
native code
what does it need to run a simple window
GUIs are OS-specific
That tells me nothing
so it needs OS-specific (non-Java) code to work
and that OS specific code is what's meant with runtime components
Like specific to the the machine it's running on?
yes
Can it run on any os? I just need windows, mac, ios and android.
Windows, MacOS and Linux works - but you need different runtime components
Android and iOS are special cases
wdym
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)
So how am i supposed to build for a different os other than my own?
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
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.
(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
What? I just need to build for different multiple os.
Idek how to build in intellij
How?
Is it a Maven project?
No
Gradle?
Idk
Do you have a pom.xml, build.gradle or build.gradle.kts file?
Nothing here gradle related
Is there a pom.xml file?
no
So you created a plain IntelliJ project without any build tool
That might make some stuff complicated
How?
How do you want users to run your application?
What application. It's a blank project..
Well you have a main method, right?
yes
yeah that's enough for me to call it application xd
Can you successfully run the application from IntelliJ?
Yes but how does this help with figuring out what to do when i need to build to another os?
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
Who is gonna hold onto a dozen devices to build?
That's dumb
And also unmanagable
That isn't necessary
at least not with Maven (or Gradle)
Then how do i build for any os from windows?
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 onewhy do i need a mac computer just to build for mac?
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.
I don't supposed you have an iso on hand?
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
So if i wanted to build for mac i would need a mac?
Depends
What exactly do you want the result to be?
Obviously an executable
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
How complicated we talkin?
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
Problems?
In my experience, it doesn't work on the first attempt.
Why is that?
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.
Is it even possible to get an application going for mac os with this?
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)
Android person?
for mobiles yes
But if you want it to run on mobile devices, that's more complicated than desktop
What's more complicated than android?
and if you want to write an application for iOS, you actually need a MacOS device to create it - because Apple mandates it
That sucks
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).
Bruh this is getting me nowhere. It's always some issue forcing me in different directions.
Why do you think people are writing either Desktop or mobile applications or two different applications (one for Desktop and one for mobile)?
Uhm for the executables..
There isn't even a concept of executables on mobiles
well technically there is but the user doesn't see it
Technically the code is being executed when the app is ran soo
yeah but you need to install the app which os an entirely different process
Not the point. Is there a library where both desktop and mobile devices have full support?
I think these libraries exist but that doesn't change that you need a Mac when building for iOS
That still sucks
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
Then i need a library that will work well on mobile
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
Why yhe hell would a mobile device need a keyboard?
or you write the application once for Desktop and once for mobile
Because most applications are written for keyboard/mouse
Which are portable to mobile
and if you rely on that, you might have difficulties with mobile devices
Why would i need a keyboard and mouse for mobile
As I said, Desktop applications are often written for users with a mouse and keyboard
while mobile applications are typically written for touchscreen use
Literally every app does this
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)
only some
and even with a library that supports both Desktop and mobile devices: one still needs a Mac to build iOS apps
most
No
I could try a forbidden method
I mean, if an app is essentially a website that's a bit of a different story
You never answered my question
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.
Is there a library that offer full mobile support?
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
Why do you keep mentiioning it
I haven't said anything about mac since the last few replies
because building for MacOS seemed important for you
Hell naw if anything i'm siding with android bc google is alot nicer with their pricing 💀
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
Eh
?
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
Thats what i meant by nicer
?
Wait they can remove my app for no reason?
well the reason being it violating their guidelines
What about friendly names?
but my username being "dan1st" was enough for that
username, not app name
Oh
They remove apps over usernames for no reason?
it's not no reason
so how can dan1st get an app removed?
They don't want any apps with things like "#1", "first" etc
and apparently this is also the case for usernames
That's dumb
That's youtube moderation ts
idk their guidelines are too confusing for me
Good thing my target isn't the app store
I don't have an issue with YT moderation.
but it is the same company
You're not a youtuber so ofc you wouldn't
lucky you
Actually, what's your definition of that?
I seen quite a few cases and heard a ton of stories of how youtube moderation is
and it's pretty dumb
I know about that
but it isn't YT being bad tbh
False moderation is bad
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
So you're telling me someone can make a false report and google have to follow it?
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.
There was something on the platform that was abusable
that's with many platforms - I don't doubt that and I think I know what you are talking about
Was it the report button?
I think not but there are multiple things
and content moderation on that scale is really hard
Why not have auto mod scan content as soon as a video is uploaded
it isn't enough
though I am not really here to talk about the reasons for that
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?
I would recommend doing so
Even if i don't need it atm?
Probably a dumb question
With a build tool, you can have reliable builds from a terminal, independently of OS and IDE
Which build system works for both windows and linux?
https://discord.com/channels/648956210850299986/1130182060410159144
For Java, both Maven and Gradle work
and these aren't OS dependent
So i could run this on windows an linux no problem?
What is gradle dsl?
the build tool doesn't care about the OS. But if you build something for one OS, it won't work on another.
Unless i build on that os?
the language Gradle uses for configurating the build
leave it default right?
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
But if i use the linux sub system then..
then you can probably also run Linux applications
Oh so then i don't have to worry about those two os
though I think if you use WSL on Win10, that doesn't work with GUI applications
what is that?
if you build JARs and not native executables/installers, you can build it on whatever platform you like
WSL?
or GUI?
wsl
Windows subsystem for Linux
Also btw i need executables for those os
it's just the abbreviation
oh short version
Are installers ok?
I mean ig but how does that relate to me getting an executable for windows and linux?
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
How so?
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)
why do java apps need an installer?
because Java needs to be installed
and the installer installs Java, JavaFX and the application
at least if configured correctly
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
that is the thing I mentioned before but idk how well this works and it's probably painful
💤
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.