0

so.. I've made a Java Class (in Eclipse) that converts an PNG image to a 5 times bigger image with sprite replacements for the colors in the original image..

I try to export it to a runnable jar, but it will not allow it.

The error message: Description Resource Path Location Type Build path specifies execution environment JavaSE-1.6. There are no JREs installed in the workspace that are strictly compatible with this environment. ImageConverter Build path JRE System Library Problem

here is the code:

package Converter;

import java.io.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;

public class changeImage {
    public static void main(String args[]) throws IOException {
        //Load map
        File file = new File("src/Converter/rcs/BaseMap.png");
        BufferedImage image = ImageIO.read(file);
        File other = new File("src/Converter/rcs/BlankMap.png");
        BufferedImage Theimage = ImageIO.read(other);


        //Read sprites
        File sprites = new File("src/Converter/rcs/Sprites.png");
        BufferedImage spriteImg = ImageIO.read(sprites);
        int r = spriteImg.getWidth() /5;
        System.out.println(r);
        int MySprites[][][] = new int[100][5][5];
        for (int k = 0; k < r; k++) {
            for (int i = 0; i < 5; i++) {
                for (int j = 0; j < 5; j++) {
                    MySprites[k][j][i] = spriteImg.getRGB((k*5)+j, i);
                }
            }
        }


        //Converter
        for (int i = 0; i < image.getHeight(); i++) {
            for (int j = 0; j < image.getWidth(); j++) {
                int color = image.getRGB(j, i);
                System.out.println(color);
                //-16777216     =(0)
                //-12629812     =(1)
                //-8421505      =(2)
                //-14503604     =(3)
                //-1237980      = 4)
                //-16735512     =(5)
                //-3584         =(6)
                //-14066        =(7)
                //-4856291      =(8)
                //-32985        =(9)
                //-3947581      =(10)
                //-4621737      =(11)
                //-7864299      =(12)
                //-20791        =(13)
                //-3620889      =(14)
                //-6075996      =(15)
                //-9399618      =(16)

              //if black convert to sprite 0
                if(color == -16777216) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a, MySprites[0][b][a]);
                        }
                    }
                }

                //if red convert to sprite 1
                if(color == -12629812) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a, MySprites[1][b][a]);
                        }
                    }
                }
              //if black convert to sprite 2
                if(color == -8421505) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a, MySprites[2][b][a]);
                        }
                    }
                }

                //if red convert to sprite 3
                if(color == -14503604) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a, MySprites[3][b][a]);
                        }
                    }
                }
              //if black convert to sprite 4
                if(color == -1237980) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a, MySprites[4][b][a]);
                        }
                    }
                }

                //if red convert to sprite 5
                if(color == -16735512) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a, MySprites[5][b][a]);
                        }
                    }
                }
              //if black convert to sprite 6
                if(color == -3584) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a, MySprites[6][b][a]);
                        }
                    }
                }

                //if red convert to sprite 7
                if(color == -14066 ) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a, MySprites[7][b][a]);
                        }
                    }
                }
              //if black convert to sprite 8
                if(color == -4856291 ) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a, MySprites[8][b][a]);
                        }
                    }
                }

                //if red convert to sprite 9
                if(color == -32985) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a, MySprites[9][b][a]);
                        }
                    }
                }
              //if black convert to sprite 10
                if(color == -3947581) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a, MySprites[10][b][a]);
                        }
                    }
                }

                //if red convert to sprite 11
                if(color == -4621737) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a, MySprites[11][b][a]);
                        }
                    }
                }
              //if black convert to sprite 12
                if(color == -7864299) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a, MySprites[12][b][a]);
                        }
                    }
                }

                //if red convert to sprite 13
                if(color == -20791 ) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a, MySprites[13][b][a]);
                        }
                    }
                }
              //if black convert to sprite 14
                if(color == -3620889) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a, MySprites[14][b][a]);
                        }
                    }
                }

                //if red convert to sprite 15
                if(color == -6075996 ) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a,     MySprites[15][b][a]);
                        }
                    }
                }
              //if black convert to sprite 16
                if(color == -9399618) {
                    for(int a = 0; a <5; a++) {
                        for(int b = 0; b <5; b++) {
                            Theimage.setRGB((j*5)+b, (i*5)+a,     MySprites[16][b][a]);
                        }
                    }
                }



            }
        }
        try {
            // retrieve image
            File outputfile = new File("src/Converter/rcs/saved.png");
            ImageIO.write(Theimage, "png", outputfile);
        } catch (IOException e) {

        }
    }
}

Any suggestions?

1 Answers1

1

Maybe you have a wrong JRE system library set up for your project. You need to remove the wrong one, and add the right one.

You will need to go to project Properties, Java Build Path, Libraries tab, remove existing JRE System Library and add yours. Take a look at the answer here.

Do notice that if you are using Maven, the problem might be happening because of settings in pom.xml, so you will need to change it, so you wouldn't have to edit project properties every time.

Community
  • 1
  • 1
alterfox
  • 1,675
  • 3
  • 22
  • 37