Note that there are some explanatory texts on larger screens.

plurals
  1. POan exportet jar file won't access resources
    text
    copied!<p>When iv'e tried to open it it could'nt find the resources. So, I've already tried to use <a href="https://stackoverflow.com/questions/15960747/exception-when-running-exported-program-but-not-in-eclipse">that solution</a> but i get another problem:</p> <pre><code>Exception in thread "main" java.lang.Error: Unresolved compilation problem: Cannot make a static reference to the non-static method getClass() from the type Object at Resources.getMainBG(Resources.java:21) at Tetris.&lt;init&gt;(Tetris.java:21) at Main.main(Main.java:5) </code></pre> <p>The current code:</p> <pre><code>import java.awt.*; import java.io.File; import javax.imageio.ImageIO; import javax.swing.ImageIcon; public class Resources { // this class import the breaks's photos into an image array named "images" private static Image[] images = new Image[7]; private static Image[] BG = new Image[3]; // 1=frame,2=pane,3=nextPane public static Image getImage(int color){ if(images[color]==null){ try{images[color] = new ImageIcon(getClass().getResource("images/block" + color + ".png")).getImage();} catch (Exception e){e.printStackTrace();System.exit(1);}} return images[color];} public static Image getMainBG() { if (BG[0] == null) BG[0] = new ImageIcon(getClass().getResource("images/MainBG.png")).getImage(); return BG[0];} public static Image getPaneBG(){ if (BG[1] == null) BG[1] = new ImageIcon(getClass().getResource("images/PaneBG.png")).getImage(); return BG[1];} public static Image getNextBG() { if (BG[2] == null) BG[2] = new ImageIcon(getClass().getResource("images/NextBG.png")).getImage(); return BG[2];} } </code></pre> <p>thank's a lot for your help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload