java - How to add resources into jar file -


i need add exel file jar it's portable. know answer using getclass().getresource.... don't have clue on how go using code.

i have exel file in src folder class files, works in netbeans not when open jar file on pc. filenotfound exception

here code have used:

public class windagelogic {    //....   public void getvalues() throws exception     {       file exel=new file("src/calculator/table1.xls");       workbook w1; //reads file       //reads file      w1 = workbook.getworkbook(exel); 

can give me code implement allow me access file jar application, i've spent weekend looking stuff on internet don't understand how can use these getresource techniques.

thanks alot

if excel file resource, can't use file manipulate rather resources, , believe read-only -- sure want do? instead load command line string tells program start looking file, or create property file tells first look.

edit 1
if using jexcel can call workbook.getworkbook(java.io.inputstream is) , resource stream via class's getresourceasstream(...) method.

e.g.,

  public void getvalues() throws exception   {      workbook w1; //reads file      w1 = workbook.getworkbook(windagelogic.class.           getresourceasstream("/calculator/table1.xls") );      //... 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -