Answer the question
In order to leave comments, you need to log in
How to correctly write paths to resources in Java?
Good day to all. I am currently learning java. I develop in intellij idea.
Undertook to implement a simple reference using javafx. The sqlite database, maven pulls up the necessary libraries to connect. Everything works while you run from idea and stops working after building in jar. In the process of studying, I realized that I was collecting it in the wrong way and with the paths I have a complete mess.
Therefore, the question is how to correctly register the paths to the resources folder?
In idea, when you create a maven project, we have the following structure
src
--main
----java
------Main
----resources
------db
--------test.db
------test.fxml
--test
pom.xml
Parent root = FXMLLoader.load(getClass().getResource("main.fxml"));
Answer the question
In order to leave comments, you need to log in
Why when calling
from Main
In the terminal givesfile:/E:/JavaProjects/test/target/classes/test.db
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question