• Post Reply Bookmark Topic Watch Topic
  • New Topic

path trouble  RSS feed

 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem running a jar file I made in another computer, but it works in th original computer, this computer is the same platform my developing computer uses. in the jar file I included a folder called Resources which contains images. when I look in the jar file the path is Resources/image.gif

in my program in the jar file I try to get

northIcon = new ImageIcon(ImageIO.read(new File(currDir + //other stuff + File.separator+ "Resources" + File.separator + "up.gif")));

Is there anything a need to watch out for when transfering programs to other computers apart from splatform specific stuff
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your use of "currDir" in the path makes me think that the image is not coming from the jar but from the file system. That would make sense because the image you are looking for would not be in the open the other computer, right?
You can use the getResource() or getResourceAsStream() methods of java.lang.Class to directly access the contents of your JAR (or any other resource in the classpath).
 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh I see, I thought because the jar was in their computer that the program would see it as being on the file system.

thanks
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!