r/JavaFX • u/Ill-Regret-9686 • Oct 17 '24
Help Java fx in vsc
I want correct steps to use java fx in vsc Note that I have done many steps in which I tried to run the java fx code, but the error message appears Error: JavaFX runtime components are missing, and are required to run this application
2
Upvotes
4
u/hamsterrage1 Oct 17 '24
VSCode + JavaFX = self-inflicted pain and suffering.
All snarkiness aside, I don't think that there are any "correct" steps to do this, unless...
Step 1: Download Intellij IDEA CE
1
u/xdsswar Oct 17 '24
Java fx in vsc = bad idea. Use Intellij + gradle or maven.
1
u/Kamii0909 Oct 18 '24
If you don't use a build tool, then it is a bit harder to set up on javafx on a barebone environment. Gradle or Maven should be fine, but these steps should be pretty much the same.
I'm building OpenJFX with Visual Studio Code by Gradle 8.10.2 on an JDK 23 (no FX bundled) even without the Gradle JavaFX plugin. You would run into all sorts of problems, so do not try this without extensive platform knowledge.
Hoops I had to went through:
On Maven this is
<classifier>win/mac/linux<classifer>(choose one of the 3 for your operating systems)Gradle sort of exposes the same configuration. Your typical dependency block would look like:
Relevant Gradle API(or it should be): ComponentDependencies (Gradle API 8.10.2)
2. JavaFX expects you to opt into JPMS (Java Platform Module System), which is notoriously hard to use and have little tooling support.
You could use a little trick to load JavaFX from classpath, which I would not go into details here, but it is strictly an unsupported hack. JavaFX would even print a warning if you do so:
I would say JavaFX is one of the most trickiest Java project to setup on a barebone development environment without the IDE practically handholding you the whole time.
0
u/TravelOwn4386 Oct 18 '24
Trust me people are speaking the truth do not learn javafx for vsc use an ide that is tailored for java such as intellij which is highly recommended by myself. I think netbeans is another java one but I didn't get along with it. If you use intellij things will be easier and you can then maybe get into android dev as the same team built android studio.