java - In maven project how i can specify a relative path to file -
in javafx project create without maven specify relative path .css file
main.class.getresource("login.css").toexternalform()
and it's work.but when create maven project , use path got runtime exception, if use path
./main/java/com/sowl/addstudent.css
or other have exception resource not found. , tried path use thred
thread.currentthread().getcontextclassloader().getresource("addstudent.css").toexternalform()
and again have runtime exception.how can specify path javafx.css.stylemanager. in advance,thx
in maven projects, resources go src/main/resources
, not src/main/java
default.
so if want call main.class.getresource("login.css")
(relative path), login.css
has in same package main, in resources directory.
if call someclassloader.getresource("addstudent.css")
or someclass.getresource("/addstudent.css")
(absolute path), addstudent.css
has directly in src/main/resources
.
Comments
Post a Comment