r/JavaFX • • Jun 15 '25

Help Please help me setup JavaFX on VS Code 🙏🏽

So as shown in the screenshots, I have been trying to setup JavaFX in VS Code for an upcoming project I have to do soon. I have tried adding the .jar files to my referenced library, manually adding them to my lib folder, adding to the .json file and nothing seems to work. Every tutorial I look up tells me the same things and I fear that I may be missing something very simple so if anyone knows what that might be then please let me know.

Any help is greatly appreciated!

10 Upvotes

22 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Jun 15 '25

So can you explain how I would transfer a project over from intellij to VS code. Im assuming just open the file in vs and it should load all the properties?

1

u/Spare-Plum Jun 16 '25

i'm sure there's a guide due porting it. But once you have the maven file the vscode maven extension should be able to figure out the build agnostic to the ide

1

u/hamsterrage1 Jun 17 '25

Go into Intellij and pick New...Project which will start up a wizard. Tell it you want a JavaFX project in Java with Maven or Gradle as the build engine. Give it a name, and set a group, something like "com.superprogrammer.firstproject", or whatever. Let the wizard run and you'll get a stupid little "Hello World" project that will show you everything you need to know although it uses FXML (boo! hiss!).

Both Maven and Gradle impose a standard project layout that is easy to understand. If you followed my instructions you'll have a src->main->java directory and then the group you specified giving the package structure.

You'll also have src->main->resources, and maybe the package structure as directories.

Run the project using the Gradle/Maven menus over at the right side of the screen. It should run perfectly without any issues or complaints.

Drag and drop your java files into the same place as the java files that the wizard created. Go into the build.gradle file, or the POM file if you are using Maven, and change "Application" section to the Main() class of your stuff. It should run.

BTW, once you have a build.gradle or POM file, double clicking it should open the project in Intellij.

1

u/hamsterrage1 Jun 17 '25

BTW, I totally forgot that I wrote a step-by-step guide for this last year. It's here: https://www.pragmaticcoding.ca/javafx/gradle-intellij

It's possibly a little bit out of date, I'll have to review it, and Intellij, Gradle, Java, and JavaFX all have new versions. Some of the tweaks I describe may not be needed any more.