Project: Javafx + Spring boot error while running the moudlar jar file
Problem: YML files (Currently using) or properties files are not getting detected, it worked fine when running in Intellij community IDE
YML files are in the jar, after extracting the jar file but still not getting detected.
(Using Module-info.java in project)
Java 21: Amazon JDK corretto
Javafx: 21
Spring boot: 3
Console error:
Standard Commons Logging discovery in action with spring-jcl: please remove commons-logging.jar from classpath in order to avoid potential conflicts
:: Spring Boot :: (v3.2.0)
14:00:32.070 [JavaFX-Launcher] INFO org.springframework.boot.SpringApplication -- Starting application using Java 21.0.2 with PID 10608 (started by person in some/folder) 14:00:32.076 [JavaFX-Launcher] INFO org.springframework.boot.SpringApplication -- No active profile set, falling back to 1 default profile: "default"
Worked solution: Worked when the jar made with the artifcat "Copy to the output directory and link via manifest"
It is not working when extracted to the traget jar
The about solution worked but extracted every dependency into the folder and it size is huge.
Needed: How to make it work when the executable jar file executed without any yml not detecting issues.
SpringBoot has many ways of finding properties. Check how it finds properties and try to use that to help debug your issue.
Usually, configurable application resources will be on a filesystem and not in a jar file (known by the Spring term "Externalized Configuration") unless they are default resources. See section 23.3 Application property files on where Spring looks for property files. You probably want your application installation to have an editable config file in one of those places so that the user can configure your application.
Additional Resources
Advice: Modularity, SpringBoot JavaFX applications, Packaging & Build Tools
This advice isn't directly an answer to your question, but some of the topics are indirectly related.
Spring as of version 6 (or SpringBoot 3) is not built to work well with Java modules (IMO). It relies on the automatic module mechanism which has numerous drawbacks. For instance, such applications cannot be linked using jlink
.
I advise using a non-modular setup (e.g. delete your module-info.java
). Information on developing non-modular JavaFX applications is at openjfx.io getting started.
To package a JavaFX application for deployment, you need to build an appropriate runtime image. I recommend packaging using a build tool (gradle or maven) possibly augmented by plugins, scripts, and command line tools like jlink
and jpackage
.
Packaging a JavaFX application as a single jar file including JavaFX modules is not a supported configuration. It breaks Java modularity which JavaFX or modular applications assume is present. Despite this, packaging a JavaFX application as a single jar file can be made to work in some circumstances. Doing so for a cross-platform application that can run on multiple platforms can result in a very large jar file, especially if the javafx-web component is used. A multi-platform executable jar including JavaFX components needs to include all JavaFX runtime components (java binaries and native code) for all possible platforms.
Packaging JavaFX applications is unfortunately a complex and sometimes difficult topic. Info is in the Packaging section of the StackOverflow JavaFX tag and also the Runtime Images section of the openjfx Getting Started documentation.