Jump to content

Image in jar

- - - - -

  • Please log in to reply
3 replies to this topic

#1
eafkuor

eafkuor

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 218 posts
I'll be brief: I'm developing a simple java application, and I want di distribute to people just a single jar file when it's done. The problem is that at the momen I have to carry a jpg together with the jar file.
Is there a way to pack the image within the jar? Or maybe I could convert the image to bytes and put it in a class?
Thanks

#2
Metalhead

Metalhead

    Newbie

  • Members
  • PipPip
  • 27 posts
There's no reason why you can't put an image in a jar-file.
If you put the image in the package before making the jar, it will be included.

(You could even put the image in manually, a jar-file is just a zip-file and you can open it with any zip-program, like 7-zip.)

#3
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
You can put it in the jar. But then you will need to change the way you access the image. Even if you've used relative paths in the code you'll need
ClassLoader.getResource()
To get the source path i think. I find it really annoying and always try to avoid it :glare:

#4
eafkuor

eafkuor

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 218 posts
Thanks guys :D




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users