Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (756)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  [LWJGL] Game not running when used in JarSplice  (Read 16004 times)
0 Members and 1 Guest are viewing this topic.
Offline Mr.CodeIt

Senior Devvie


Medals: 2
Projects: 1



« Posted 2014-05-08 20:23:32 »

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. Cry
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #1 - Posted 2014-05-08 20:39:57 »

After that it is created but it pops up for a halfsecond and closes. Cry

...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.
Offline Drenius
« Reply #2 - Posted 2014-05-08 20:44:12 »

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.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mr.CodeIt

Senior Devvie


Medals: 2
Projects: 1



« Reply #3 - Posted 2014-05-08 20:49:14 »

After that it is created but it pops up for a halfsecond and closes. Cry

...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.


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

Senior Devvie


Medals: 2
Projects: 1



« Reply #4 - Posted 2014-05-08 21:01:39 »

Error in cmd Test:


Microsoft Windows [Version 6.1.7601]
Copyright (c) 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>
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #5 - Posted 2014-05-08 21:18:45 »

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

1  
java -jar FlubberSpace.jar
Offline Mr.CodeIt

Senior Devvie


Medals: 2
Projects: 1



« Reply #6 - Posted 2014-05-08 21:56:42 »

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

1  
java -jar FlubberSpace.jar


it says Microsoft Windows
 [Version 6.1.7601]
Copyright (c) 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>
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #7 - Posted 2014-05-08 22:09:37 »

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:

1  
2  
3  
4  
5  
6  
7  
// starting from C:\Users\Owner>

cd desktop
// press enter

java -jar yourJarFileName.jar
// press enter again
Offline Mr.CodeIt

Senior Devvie


Medals: 2
Projects: 1



« Reply #8 - Posted 2014-05-08 23:43:55 »

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:

1  
2  
3  
4  
5  
6  
7  
// 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:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
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>
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #9 - Posted 2014-05-08 23:45:54 »

Well what's MainFS.java:68 look like?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mr.CodeIt

Senior Devvie


Medals: 2
Projects: 1



« Reply #10 - Posted 2014-05-09 00:23:48 »

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.
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #11 - Posted 2014-05-09 00:38:27 »

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.
Offline Mr.CodeIt

Senior Devvie


Medals: 2
Projects: 1



« Reply #12 - Posted 2014-05-09 01:31:10 »

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:
1  
2  
wood = TextureLoader.getTexture("PNG", new FileInputStream(
               new File("res/FlubberFlap.png")));


I use
1  
playerimg.bind()
to start drawing it.

I really don't mean to anoy *annoy you, I'm just new to certain things.
Quite frankly it seems you don't know enough about how your computer and operating system works, some people may say otherwise but that's another key thing in programming.  Pointing

Then again, I've been programming less than a year. Cut some slack.
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #13 - Posted 2014-05-09 01:45:08 »

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

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


That should work.

For future reference, you can't use
File
when the resource is in a jar file.
Offline Jacob Pickens
« Reply #14 - Posted 2014-05-09 01:49:14 »

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!

Offline Mr.CodeIt

Senior Devvie


Medals: 2
Projects: 1



« Reply #15 - Posted 2014-05-09 02:00:12 »

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?
Offline Mr.CodeIt

Senior Devvie


Medals: 2
Projects: 1



« Reply #16 - Posted 2014-05-09 02:04:19 »

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

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


That should work.

For future reference, you can't use
File
when the resource is in a jar file.


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? :
1  
2  
3  
4  
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.
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #17 - Posted 2014-05-09 02:49:05 »

Put the res folder in the src folder, then try it.
Offline Mr.CodeIt

Senior Devvie


Medals: 2
Projects: 1



« Reply #18 - Posted 2014-05-09 02:51:34 »

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?
Offline SHC
« Reply #19 - Posted 2014-05-09 02:53:36 »

First step is make sure you have the resources bundled with the JAR you create. Try to move the
res/
folder inside the
src/
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.

Offline Mr.CodeIt

Senior Devvie


Medals: 2
Projects: 1



« Reply #20 - Posted 2014-05-09 03:09:09 »

First step is make sure you have the resources bundled with the JAR you create. Try to move the
res/
folder inside the
src/
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.

Is the res supposed to be a source folder in the src/ folder? If so I can't put it in :


Or do I make a regular folder inside of the src/:
Offline SHC
« Reply #21 - Posted 2014-05-09 03:40:57 »

The second picture is the one I said.

Offline Gibbo3771

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Reply #22 - Posted 2014-05-09 03:49:58 »


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


We would cut you some slack but frankly people get quite annoyed when people ask questions before trying to find a solution themselves.

Also it seems most of the advice given to you is completely ignored.

Such as learn a little more Java, in this situation running from the command line is the first thing you should have done (also one of the first things taught in any book worth a salt) , not made another forum post.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline Mr.CodeIt

Senior Devvie


Medals: 2
Projects: 1



« Reply #23 - Posted 2014-05-09 03:50:12 »

The second picture is the one I said.

Okay, After that do I just add that file on my desktop as a jar?:



Then get natives from  where I downloaded it?:
Offline Cero
« Reply #24 - Posted 2014-05-09 04:03:57 »

btw this is exactly like my first experience with jarSplice, which is why it sucks imo.
you should never have to pack resources in the source folder, or pack everything into a fat jar
some of you might prefer that but I think its ugly as hell.
in the end I wanna have one exe that is like 100 kb and an assets folder or pack

so yeah jarsplice is very picky about the resources and stuff.

I havent tried packr. I do own JET which worked fine. Usually I just pack it myself with an nullsoft installer an use batch-to-exe to run.

Offline Mr.CodeIt

Senior Devvie


Medals: 2
Projects: 1



« Reply #25 - Posted 2014-05-09 11:02:36 »


so yeah jarsplice is very picky about the resources and stuff.


Can't this be done manually?
Offline Opiop
« Reply #26 - Posted 2014-05-09 13:09:23 »

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


Im not talking about that. If your on windows how do you not know how these basic things work.  Huh
First off, *you're

Second, do you have anything constructive to add to the conversation, or are you just going to insult OP for not knowing how to do something? Guess what, people don't know exactly the same things as you just because you've learned them before.

OP, what do you mean by manually? Packing the Jar? Yes, but JarSplice isn't the issue here. The issue is how you are loading your resources. Java is (for lack of a better term) picky about how you load resources in, in different situations. Blaming JarSplice for Java's confusing IO library is not going to get you a solution.
Offline SHC
« Reply #27 - Posted 2014-05-09 13:25:13 »

Maybe there should be some tutorials on resource loading.

http://stackoverflow.com/a/3862115/1026805

http://www.thinkplexx.com/learn/howto/java/system/java-resource-loading-explained-absolute-and-relative-names-difference-between-classloader-and-class-resource-loading

Offline Mr.CodeIt

Senior Devvie


Medals: 2
Projects: 1



« Reply #28 - Posted 2014-05-09 19:38:29 »


This is how I did it with Java2D. Right now the
1  
img  = this.getClass().getResource("foo.txt");
gives an error. I'll try to rephrase the question, How do I load textures from the Slick_util.jar into a fat jar. I watched videos on how and I can easily get the libraries and jars, it's just I don't have the textures when I run it. I put the res/ folder in the src/ folder now. The textures don't load still ofcourse.
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 485
Exp: 7 years



« Reply #29 - Posted 2014-05-09 19:45:01 »

This is how I did it with Java2D. Right now the
1  
img  = this.getClass().getResource("foo.txt");
gives an error. I'll try to rephrase the question, How do I load textures from the Slick_util.jar into a fat jar. I watched videos on how and I can easily get the libraries and jars, it's just I don't have the textures when I run it. I put the res/ folder in the src/ folder now. The textures don't load still ofcourse.

Either use
1  
img  = this.getClass().getClassLoader().getResourceAsStream("res/foo.txt");
or
1  
img  = this.getClass().getResourceAsStream("/res/foo.txt");


Notice the "/" if you don't use getClassLoader(). Also, the AsStream part is necessary.
Pages: [1] 2
  ignore  |  Print  
 
 

 
DesertCoockie (53 views)
2018-05-13 18:23:11

nelsongames (84 views)
2018-04-24 18:15:36

nelsongames (75 views)
2018-04-24 18:14:32

ivj94 (760 views)
2018-03-24 14:47:39

ivj94 (88 views)
2018-03-24 14:46:31

ivj94 (644 views)
2018-03-24 14:43:53

Solater (103 views)
2018-03-17 05:04:08

nelsongames (185 views)
2018-03-05 17:56:34

Gornova (427 views)
2018-03-02 22:15:33

buddyBro (1087 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!