[LWJGL] Game not running when used in JarSplice

I have a game I want to display but whenever I run it after I splice it, it pops up for a second and disappears. These are the steps I took.

*Export my game to the desktop with it’s libraries.

*I create and selected my location of the jar file

After that it is created but it pops up for a halfsecond and closes. :’(

…And what’s the stacktrace say?

You can figure out the problem in 30 seconds looking at the stacktrace, or you can spend 5+ minutes making a forum post with which noone can help you without a stacktrace anyway.

Default behavior in this situation should be to run in command line and check the trace.

Not sure, but “Copy required librarys into a sub-folder next to the generated JAR”
sounds like it will expect them there (in the sub-folder) and if JarSplice places them virtually in the same folder as the JAR this won’t work.
Might be wrong.

If you’re talking about when I export it, then there isn’t any error. This works for other games, just not this one

Error in cmd Test:

Microsoft Windows [Version 6.1.7601]
Copyright © 2009 Microsoft Corporation. All rights reserved.

C:\Users\Owner>
C:\Users\Owner>java -cp .;res;jar\lwjgl.jar;jar\lwjgl_test.jar;jar\lwjgl_util.ja
r;jar\lwjgl_fmod3.jar;jar\lwjgl_devil.jar;jar\jinput.jar;
Usage: java [-options] class [args…]
(to execute a class)
or java [-options] -jar jarfile [args…]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the “server” VM
The default VM is server.

-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
              A ; separated list of directories, JAR archives,
              and ZIP archives to search for class files.
-D<name>=<value>
              set a system property
-verbose:[class|gc|jni]
              enable verbose output
-version      print product version and exit
-version:<value>
              require the specified version to run
-showversion  print product version and continue
-jre-restrict-search | -no-jre-restrict-search
              include/exclude user private JREs in the version search
-? -help      print this help message
-X            print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
              enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
              disable assertions with specified granularity
-esa | -enablesystemassertions
              enable system assertions
-dsa | -disablesystemassertions
              disable system assertions
-agentlib:<libname>[=<options>]
              load native agent library <libname>, e.g. -agentlib:hprof
              see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
              load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
              load Java programming language agent, see java.lang.instrument

-splash:<imagepath>
              show splash screen with specified image

See http://www.oracle.com/technetwork/java/javase/documentation/index.html for m
ore details.

C:\Users\Owner> -Djava.library.path=native\windows org.lwjgl.test.WindowCreat
ionTest
‘-Djava.library.path’ is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Owner>

Umm… you pressed enter while typing the command. Also, why all the classpath and librarypath stuff? That’s jarsplice’s job.

Just navigate to the desktop (or where ever the “fat jar” created by jarsplice is) and


java -jar FlubberSpace.jar

it says Microsoft Windows
[Version 6.1.7601]
Copyright © 2009 Microsoft Corporation. All rights reserved.

C:\Users\Owner>java -jar FLIPPERFLAP1.0.jar
Error: Unable to access jarfile FLIPPERFLAP1.0.jar

C:\Users\Owner>

My god dude.

When the prompt says “C:\Users\Owner>” and the file is in “C:\Users\Owner\Desktop>,” it won’t work because the file’s not there.

So, to preemptively answer your next question:


// starting from C:\Users\Owner>

cd desktop
// press enter

java -jar yourJarFileName.jar
// press enter again

I really don’t mean to anoy you, I’m just new to certain things. Anyway the error is the image can’t be loaded somehow. Do I create a file holding all the images and stuff in the c drive with file I/o?

Message:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Owner>cd desktop

C:\Users\Owner\Desktop>java -jar FLIPPERFLAP1.0.jar
java.io.FileNotFoundException: res\FlubberFlap.png (The system cannot find the p
ath specified)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:131)
        at FSMain.MainFS.main(MainFS.java:68)

C:\Users\Owner\Desktop>
C:\Users\Owner\Desktop>

Well what’s MainFS.java:68 look like?

It has the main method with a game loop. In my initialization method I have a texture called FlubberFlap.png. The image is in a source folder called res. When I run it with the IDE all the images work. Don’t professional developers make a file holding game data? I’m not sure but I can give you source code if I’m not too clear.

What is line 68?

If you’re trying to load files from inside the jar file (/res) then if you’re not using getResourceAsStream(), your’e doing it wrong, and that’s why it breaks when exported.

I use this at 68:

wood = TextureLoader.getTexture("PNG", new FileInputStream(
					new File("res/FlubberFlap.png")));

I use

playerimg.bind()

to start drawing it.

Then again, I’ve been programming less than a year. Cut some slack.

Well, if getTexture() accepts an InputStream (not specifically a FileInputStream) then change it to this:


wood = TextureLoader.getTexture("PNG", MainFS.class.getClassLoader().getResourceAsStream("res/FlubberFlap.png"));

That should work.

For future reference, you can’t use [icode]File[/icode] when the resource is in a jar file.

You could, alternatively, just copy the res folder in your project and put that in the same folder as your Fat Jar. Then distribute the folder with the jars. This way you could let your players edit the graphics and have texture-packs!

That’s cool, but wouldn’t they be able to see and use the source code?

The res source folder isn’t in the package by the way, and I get this error when I run it. Do I pu the image in a different location, preferably the same package? :

Exception in thread "main" java.lang.NullPointerException
	at org.newdawn.slick.opengl.TextureLoader.getTexture(TextureLoader.java:64)
	at org.newdawn.slick.opengl.TextureLoader.getTexture(TextureLoader.java:24)
	at FSMain.MainFS.main(MainFS.java:67)

Line 67 is the code you gave me.

Put the res folder in the src folder, then try it.

In the package too? The res folder is a source folder do I make it a regular one?

First step is make sure you have the resources bundled with the JAR you create. Try to move the [icode]res/[/icode] folder inside the [icode]src/[/icode] folder. And export the jar like this.

And create the fat jar as you did. This gets rid of the Eclipse’s JAR in JAR loader.