# Running Slick2d outside of the IDE

I am looking for advice how to solve an exception I am getting,

I've looked around and seen people get the same error but most people whom had it seems to run on old graphics drivers and once they fixed that it seemed to work for most people.

I doubt that's the reason causing it for me since I have the latest nVidia drivers and the game runs well from the IDE. I also did create a jar of the game before I implemented Slick2d and that ran without exceptions.

I used to get another exception, that it couldn't find the right natives for lwjgl so I removed the natives from the build and made a fat jar with jarsplice and added them during that process and that's when I ended up at this point.

I've tried and tried for days and it's probably something really stupid and easy to fix but I havn't built a lot of project to be ran from outside Eclipse so any help would be greatly appreciated.

Some basic info on my rig:

OS: Windows 7: Enterprise

CPU: Intel Core i7-2600K

GPU: nVidia GTX 980

RAM: 8192MB (forgot the brand and make, it's old lol)

The first thing you should check is if the natives are in your class path and are up to date with the version of LWJGL you're using.

It's also possible that your graphics drivers are out of date, or your card doesn't support the version of OpenGL you're trying to initialize. Windows 10 is usually the culprit in this case:

Some versions of LWJGL can cause problems with newer JDK builds. Find out which JDK your version of LWJGL is built with. If you can't find that information, try building on JDK 7. If that doesn't work, try JDK 8.

Please let me know which, if any, solved your problem.

Thanks.

• Is there an effective way to change which Java version builds from Eclipse or from CMD? – Kazzeroth Feb 5 '17 at 1:40
• I use IntelliJ (because eclipse is terrible), so I wouldn't know. But a quick Google search gave me stackoverflow.com/questions/13635563/setting-jdk-in-eclipse – Oliver Yasuna Feb 5 '17 at 1:43
• I suggest you check the other two possible fixes I listed first before installing another JDK version. – Oliver Yasuna Feb 5 '17 at 1:46
• I am very, very sure that I am using my latest drivers since I recently had to reinstall them to be able to play Battlefield 1 with my buddy. As for LWJGL drivers I tried changing the natives out from a newer version as I was using the ones that came with Slick but that didn't run for other reasons. As I said though it runs 100% from the IDE so that seems improbable still. ;/ – Kazzeroth Feb 5 '17 at 1:49
• So it works in the IDE, but not from command line? – Oliver Yasuna Feb 5 '17 at 3:53

For anybody who has this issue in the future, slicks Image class can't be initialized pointing to an image in a jar in a straight forward kind of way.

Just move them outside to the jar directory and call them with something like

    Image img;

public static void main(String[] args) throws URISyntaxException {
CodeSource codeSource = Board.class.getProtectionDomain().getCodeSource();
String sourceCoded = codeSource.getLocation().toURI().toString();
try {
sourceDecoded = java.net.URLDecoder.decode(sourceCoded, "UTF-8").substring(5);
sourceDir = sourceDecoded.substring(0, sourceDecoded.lastIndexOf("/"));
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
img = new Image(Board.sourceDir+"/art/"+"specificImagePath.png");}