title: Executable jar with libgdx: asset not found
body: <p>I created a little Game using the libgdx libraries and exported it to an executable jar. In Eclipse the Game works fine but the jar crashes with:</p>
  
  <pre><code>PS E:\Workspaces\JavaGames\Executable Jars&gt; java -jar Pk2.jar
  SetToNewScreen called
  Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: img/player/player_16_down.png
      at com.badlogic.gdx.graphics.Pixmap.&lt;init&gt;(Pixmap.java:140)
      at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
      at com.badlogic.gdx.graphics.Texture.load(Texture.java:130)
      at com.badlogic.gdx.graphics.Texture.&lt;init&gt;(Texture.java:121)
      at com.badlogic.gdx.graphics.Texture.&lt;init&gt;(Texture.java:100)
      at com.badlogic.gdx.graphics.Texture.&lt;init&gt;(Texture.java:92)
      at org.hofrob.entities.Player.&lt;init&gt;(Player.java:29)
      at org.hofrob.screens.misc.Play.show(Play.java:121)
      at com.badlogic.gdx.Game.setScreen(Game.java:61)
      at org.hofrob.screens.Screenmanager.setToNewScreen(Screenmanager.java:63)
      at org.hofrob.pkgame.MyPkGame.create(MyPkGame.java:20)
      at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
      at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
  Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: img\player\player_16_down.png (Internal)
      at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
      at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:220)
      at com.badlogic.gdx.graphics.Pixmap.&lt;init&gt;(Pixmap.java:137)
      ... 12 more
  </code></pre>
  
  <p>The problematic line is:</p>
  
  <pre><code>private final Sprite player_down =
      new Sprite(new Texture("img/player/player_16_down.png"));
  </code></pre>
  
  <p>I followed <a href="https://github.com/libgdx/libgdx/wiki/Deploying-your-application" rel="nofollow">the libgdx wiki</a> to create the jar. The assets folder is included in the build path and the content of the assets folder is in the exported jar:</p>
  
  <ul>
  <li>/com</li>
  <li>/img</li>
  <li>/javazoom</li>
  <li>/META_INF</li>
  <li>/net</li>
  <li>/org</li>
  <li>/tiles</li>
  <li>...</li>
  </ul>
  
  <p>I also tried using <code>Gdx.files.internal</code> (also, removing <b>final</b>)</p>
  
  <pre><code>private final Sprite player_down = new Sprite(new Texture(Gdx.files.internal("img/player/player_16_down.png")));
  </code></pre>
  
  <p>but there was no difference.</p>
  
  <p>I am able to export the basic project, which exists when a new gradle project is imported into eclipse as an executable jar (without errors when executing the jar).</p>
  
  <p>Similar questions I found had the problem that the assets folder was not included in the jar, which doesn't seem to be a problem here. </p>
  
  <p>Any ideas?</p>