Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

When I run a jar file I created, I get the following error, so please someone help me out of this:

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: img/black_ring.png at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:137) at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:55) at com.badlogic.gdx.graphics.Texture.load(Texture.java:175) at com.badlogic.gdx.graphics.Texture.create(Texture.java:159) at com.badlogic.gdx.graphics.Texture.(Texture.java:133) at com.badlogic.gdx.graphics.Texture.(Texture.java:122) at com.badlogic.runningball.UserBall.(UserBall.java:19) at com.badlogic.runningball.GameScreen.(GameScreen.java:25) at com.badlogic.runningball.RunningBall.create(RunningBall.java:12) at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:126) at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:113) Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: img/black_ring.png (Internal) at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:108) at com.badlogic.gdx.files.FileHandle.length(FileHandle.java:364) at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:156) at com.badlogic.gdx.graphics.Pixmap.(Pixmap.java:134) ... 10 more

share|improve this question
2  
If you don't even write the command line you used... –  Lohoris Apr 5 '12 at 8:44
1  
stackoverflow.com could be a better place to put this kind of question, I think... –  NemoStein Apr 5 '12 at 13:16
add comment

2 Answers

The problem in this case is that the file img/black_ring.png is missing from the JAR-file. You need to add it, else the application can't start. Any application able to handle a JAR file as ZIP archive enables you to do so.

For a description on how you create a fitting file directly your question contains far to less information. Information like how you created this JAR file in the first place and the IDE and/or buildsystem you used are essential to get a good answer.

share|improve this answer
    
I am using eclipse IDE to create the jar file and I found that error so provide guidance –  Siddharth Apr 6 '12 at 5:12
    
At jar file creation time I found an error –  Siddharth Apr 6 '12 at 5:23
add comment

Use the program 7zip, or, on if you are on a Unix system it should have tar installed, which is what a Jar is: a Java tar.

I'm not sure what your development environment is, but you seem to be lacking the fundamental knowledge of how an executable jar works.

For a jar to be executable, it needs a manifest file. This file tells java what your main class file is, i.e:

Manifest-Version: 1.0
Main-Class: package.names.MainClass

I see you are also using LWJGL. To use that, you will also need to specify the classpath variable in the manifest, so it will now look like this:

Manifest-Version: 1.0
Main-Class: package.names.MainClass
Class-Path: lwjgl.jar

This assumes that lwjgl.jar will be in the same folder as your executable jar. IIRC lwjgl also requires native libraries, so you will have to set that as an argument to the Java VM, try this: http://lmgtfy.com/?q=lwjgl+manifest

Edit: Just realized I forgot to say how to actually create the jar!

To create the jar file, you use the jar command:

jar cvfm output.jar manifest *.class

For finding all the class files, on Linux I use this handy command

find . -iname '*.class' | sed 's:\./::' > filelist

to get all the class files in all the subdirectories of your current location and output them into the file 'filelist'.

(I'm sure there is an easier way, but that's how I do it)

then you can use the command

jar cvfm output.jar manifest @filelist

without worrying about having to recurse into subdirectories looking for classes

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.