Sign in to follow this  

[java] Embedded images/sounds?

This topic is 4107 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Is embedded resources supported in Java? The thing is that I want my images/sounds to be embedded in the exe-file. (I dont want them to be individual files in my .jar-file) One solution that works for small images is to save the pixel-indexes (palette-indexes) and the palette-data as two separete arrays. Then you create the image on the fly by MemoryImageSource, IndexColorModel and Toolkit.getDefaultToolkit().createImage(MemoryImageSource). But now I have a quite large image and get the error: "The code of constructor MyPanel() is exceeding the 65535 bytes limit". The code:
public class MyPanel() extends JPanel {
 private int[] palette = {...};
 private int[] pixels = {...}; // To large, exceeding 65536 bytes.
 
 public MyPanel() {
  ...
 }

The error is shown at line "public MyPanel() {". Is this way to solve the problem impossible? Maybe there is another way to have "embedded" images? Kind Regards

Share this post


Link to post
Share on other sites
Quote:
Original post by CodeMachine
Is embedded resources supported in Java?
The thing is that I want my images/sounds to be embedded in the exe-file.
(I dont want them to be individual files in my .jar-file)

As far as Java is concerned, adding them as files is equivilent to embedding resources in an exe. Why don't you want to do this?

IMHO the closest you can reasonably get is to serialise your resources into a file and include that in your jar.

Share this post


Link to post
Share on other sites
Quote:
Original post by OrangyTang
Quote:
Original post by CodeMachine
Is embedded resources supported in Java?
The thing is that I want my images/sounds to be embedded in the exe-file.
(I dont want them to be individual files in my .jar-file)

As far as Java is concerned, adding them as files is equivilent to embedding resources in an exe. Why don't you want to do this?


Hi OrangyTang
I dont want the user to be able to edit my images/sounds.

Another way to control this is to calculate a checksum for each image/sound, and having them as separate files in my .jar.

But back to my question...
Is there a way to store more than 65535 bytes?
Or is it impossible?

Kind Regards

Share this post


Link to post
Share on other sites

This topic is 4107 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this