2013-10-16 20 views
0

所以..我做了一個Java類(在Eclipse),一個PNG圖片精靈替代原始圖像中的顏色轉換到5倍大的圖像..化妝獨立,不會出口

我嘗試將它導出到可運行jar,但它不會允許它。

錯誤消息: 描述資源路徑位置類型 構建路徑指定執行環境JavaSE-1.6。工作區中沒有安裝與此環境嚴格兼容的JRE。 ImageConverter構建路徑JRE系統庫問題

這裏是代碼:

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) { 

     } 
    } 
} 

有什麼建議?

回答

1

也許你的項目設置了錯誤的JRE系統庫。你需要刪除錯誤的,然後添加正確的。

您將需要轉到項目屬性,Java構建路徑,庫選項卡,刪除現有的JRE系統庫並添加您的項目。看看答案here

請注意,如果您使用的是Maven,由於pom.xml中的設置,問題可能會發生,因此您需要對其進行更改,這樣您就不必每次都編輯項目屬性。

+0

我感謝你,這工作,因爲它應該:) *將接受答案在7分鐘;) – JavaApprentis