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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -