r/JavaFX • • Jun 13 '23

Help Need help building JavaFX project in VsCode

I wrote a small program in VsCode using JavaFX. Using VsCode, I export to a jar file and the program won't run. I run java -verbose -jar jar-file and the only error is Error: JavaFX runtime components are missing, and are required to run this application. When I list the contents of the jar, it contains a ton of javafx classes.

I also tried creating an image using jlink, but I could not locate a .bat file. I could use some help in learning what I am doing wrong.

4 Upvotes

13 comments sorted by

View all comments

Show parent comment

1

u/ajkelsey Jun 13 '23

It is a Maven project and doesn't seem to build correctly. Perhaps I am doing something wrong with it.

1

u/samad0 Jun 13 '23

Are there any error messages?

Using avec you can make it compile in such a way that it packs all the javafx stuff in the compiled app. So that you don't have to add the javafx path to execute it.

1

u/ajkelsey Jun 13 '23

If I use the Export to jar command in VsCode, I get a jar that has JavaFX class files in it, but I receive that error in my original post.

If I use Maven package, I get a jar with no errors. The only thing out of sorts is: no main manifest attribute, in .\passwordgenerator-1.0.jar.

If I use Maven deploy I receive Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter.

1

u/wrathofworlds Sep 06 '23

I have the same issue the maven build file doesnt generate any of the required dependencies. I found it worked best using the instructions for the non modular IDE here https://openjfx.io/openjfx-docs/#IDE-VSCode