java - executable jar from eclipse unable to use images within packages... sometimes -


i have wrote swing application , works fine in eclipse when export runnable jar parts of application fail, when dealing images, line example;

logo = getclass().getresource("/com/cogentautomation/logo.jpg").getpath(); 

eclipse packaging images in com.cogentautomation package , can see in .jar itself, have tried both export methods, extract required libraries , package required libraries, 1 says;

filenotfoundexception com\cogentautomation\logo.jpg 

the other says;

filenotfoundexception file:\c:\documents\hs.jar!\com\cogentautomation\logo.jpg 

i using library parse out pdf file, error occurring, works in eclipse , other images on disk aren't java resource.

i've read other topics on problem nothing seemed help.

edit: addressing in comments, require string variable library using requires string input read image;

import org.pdfclown.documents.contents.entities.image;  image image = image.get(logo); 

based on javadocs org.pdfclown.documents.contents.entities.image "guess" image.get(string) forwarding call image.get(file) using string parameter constructor of file

this isn't going work url based paths. instead, need towards image.get(iinputstream) (why these apis can't use what's available :p)

so, digging through api more iinputstream leads org.pdfclown.bytes.buffer, not perfect, it's link.

you can use class#getstreamasresource , write bytearrayoutputstream can give byte[], can pass image.get(iinputstream)


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -