Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (601)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  A problem generating a jar file  (Read 1453 times)
0 Members and 1 Guest are viewing this topic.
Offline smellyfish

Junior Newbie

« Posted 2005-11-17 00:10:15 »


I have a project I'm working on for one of my classes.  It's a little pong game, nothing complicated.  Actually, my game setup is very similar to the Arkanoids101 setup.  Now here's the problem.  For my project I'm using NetBeans, I recreated the Arkanoids101 in the SDK and after I got it to work, I could run the .jar file for that project and it functioned just fine.  Then I created my game, implemented the game setup and all the game logic, but when I try to run the .jar file created for it, the game window pops up for a second and disappears.  Nothing else happens.  Any ideas?
Offline Jeff

JGO Coder

Got any cats?

« Reply #1 - Posted 2005-11-17 00:18:41 »

How are you running the Jar file?  If you arent running it from teh command line, do so and look at the output.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!
Offline smellyfish

Junior Newbie

« Reply #2 - Posted 2005-11-17 03:06:41 »

Well i was just double clicking the file :O  I ran the file from the command file, but i simply went to the directory and did: arkanoids.jar.  The same thing happened and nothing printed in the prompt ><  Should I run it from command line using the java application command or something?  Sorry for the noobness QQ  And thanks for the help Cheesy
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline hvor2

Junior Devvie

Beyond mind, there is an awareness...

« Reply #3 - Posted 2005-11-17 08:16:59 »

Go to your directory (in command prompt). Than type
java -jar  arkanoids.jar

and you should be able so see some output, as Jeff suggested...

Offline smellyfish

Junior Newbie

« Reply #4 - Posted 2005-11-18 00:02:05 »

Alright, I got some out put now.  I keep all my gif's in my project in a folder called sprites, so when I load an image for an object , say : Entity brick = new BrickEntity(this,"sprites/brick.gif",100+(x*50),(50)+row*35);  Now when I run the jar file from the command prompt I get this message: can't find ref: sprites/ball.gif.  I tried puting the jar file in the same directory as the sprites forlder but that didn't help Sad  Any ideas?
Offline oNyx

JGO Coder

Medals: 2

pixels! :x

« Reply #5 - Posted 2005-11-18 00:17:34 »

BufferedImage i;
try { BufferedInputStream(getClass().getResourceAsStream("/tex/foo.png")));
}catch(IOException e){

The '/' at the beginning ensures that it searches from the "root" of the classpath (its kinda absolute). This means that it doesnt matter where you are currently in the hirachy... the resource will always be found.

The BufferedInputStream bit is a workaround for some imageio bug.

If getClass() doesnt work (static context) write the full class name (eg FooBar.class) instead.

This approach always works... jar-ed or not.

弾幕 ☆ @mahonnaiseblog
Offline smellyfish

Junior Newbie

« Reply #6 - Posted 2005-11-18 01:05:06 »

Check this out, oNyx, I tried to use the code that you posted and that's what i ended up with:
public Sprite getSprite(String ref) {
   // if we've already got the sprite in the cache
   // then just return the existing version
   if (sprites.get(ref) != null) {
      return (Sprite) sprites.get(ref);
                BufferedImage sourceImage = null;
                try {
                if(sourceImage == null)
                    fail("Can't find ref: "+ref);
                }catch(IOException e){
   // create an accelerated image of the right size to store our sprite in
   GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
   Image image = gc.createCompatibleImage(sourceImage.getWidth(),sourceImage.getHeight(),Transparency.BITMASK);
   // draw our source image into the accelerated image
   // create a sprite, add it the cache then return it
   Sprite sprite = new Sprite(image);
   return sprite;

The parameter ref that comes in to the function is for example "/sprites/ball.gif"
I tried to run the jar file with this and the code still breaks at the fail in this function and I still get this message: Can't find ref: /sprites/ball.gif
Am I doing something wrong again? >< thx for all the help. Smiley
Offline oNyx

JGO Coder

Medals: 2

pixels! :x

« Reply #7 - Posted 2005-11-18 02:36:40 »

Does any jar in the classpath contain a directory called "sprites" with "ball.gif" in it?

Or is there a directory called "sprites" (with "ball.gif" in it) in the directory you're starting your application from?

弾幕 ☆ @mahonnaiseblog
Offline smellyfish

Junior Newbie

« Reply #8 - Posted 2005-11-18 03:00:49 »

I put a folder named sprites with all the pictures in it in the same directory as the jar file
Offline smellyfish

Junior Newbie

« Reply #9 - Posted 2005-11-18 04:25:48 »

Oh my god, i am a frikking idiot!!!! QQ
Wow, i really hate myself right now :*(

So..... When I created all the sprites for my game, I made them in paint, and guess what format it saved them in?  .GIF !!!!!!
I just spent an entire day thinking I was getting some crazy error and it turns out that all my files were .GIF's instead of .gif's.

But anyway, thanks for all your help fellas, you are awesome! Keep it up!!!

Catch ya later Cheesy
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oNyx

JGO Coder

Medals: 2

pixels! :x

« Reply #10 - Posted 2005-11-18 05:22:24 »

Oh yea... always use lowercase extensions. I have the feeling that microsoft did that on purpose... Afaict paint is the only program which tends to use uppercase file extensions.

弾幕 ☆ @mahonnaiseblog
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Riven (32 views)
2015-07-27 16:38:00

Riven (16 views)
2015-07-27 15:35:20

Riven (20 views)
2015-07-27 12:26:13

Riven (10 views)
2015-07-27 12:23:39

BurntPizza (27 views)
2015-07-25 00:14:37

BurntPizza (39 views)
2015-07-24 22:06:39

BurntPizza (22 views)
2015-07-24 06:06:53

NoxInc (25 views)
2015-07-22 22:16:53

NoxInc (17 views)
2015-07-22 22:13:39

Jesse (40 views)
2015-07-22 03:10:36
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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‑
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!