java - Maven Jar file read external images -
hello changed javafx8 project maven works except loading files lying next jar. worked before not more.
folder structure:
icons load located in /target/icons jar file located in /target
my code read files following:
string applicationdir = (new file(".")).getabsolutepath(); string iconsdir = applicationdir+"/target/icons/"; file[] files = new file(iconsdir).listfiles(); (file file : files) { if (file.getname().endswith(".png")) { system.out.println(file.getabsolutepath()); image img = new image(file.getabsolutepath()); iconlibrary.put(file.getname().split("\\.")[0].touppercase(), img); } }
it enters loop , findes files, crashes when new image(file.getabsolutepath()) called invalid url: invalid url or resource not found exception.
i tried kind of stuff toexternalform() , on nothing helped, still exception no matter do.
i lost , maybe can give me hint doing wrong.
thanks in advance
robi
hey guys got running!
the solution was:
image img = new image(file.touri().tostring());
thanks help
what weird, makes difference in directory running java -jar jarfile.jar works if in same folder
Comments
Post a Comment