Java - Retrieve image on the server side -
i trying retrieve image display in pdf (this on server side). however, no mater path try null pointer exception. code is:
try { //option 1 classloader classloader = thread.currentthread().getcontextclassloader(); system.out.println("image path 1"); string path = classloader.getresource("image/1ster_icon_256.png").getpath(); //string path = classloader.getresource("/image/1ster_icon_256.png").getpath(); //string path = classloader.getresource("war/image/1ster_icon_256.png").getpath(); //string path = classloader.getresource("/war/image/1ster_icon_256.png").getpath(); system.out.println("image path = " + path); image image1 = image.getinstance(path); preface.add(image1); document.add(preface); } catch(exception e){ e.printstacktrace(); } }
and error is:
image path 1 java.lang.nullpointerexception
i have tried other examples search; however, have code exceptions.
Comments
Post a Comment