runs in compiler but not jar file

hey sorry if this is in the wrong place.

Okay so my game runs great in the compiler.

in my game it waits for a key input before starting.

so when I runt he jar file it has a blank screen(that is normal) and then when I press a button it closes(that is not usual)

this (obviously) does not happen in the compiler.

thanks in advance :slight_smile:

hey sorry if this is in the wrong place.

Yes, it’s the wrong place. This thread should be over in newless cluebies.

Okay so my game runs great in the compiler.

IDE.

[…]when I press a button it closes[…]

Start it from the console (java -jar foo.jar) and take a look at the exception.

here is error. I think I know waht the problem is, it is that it cannot findt he files although it has them.

that is what the last part in spanish mean. it is saying that it cannot find the files. the rest also appears in the normal IDE.

here it is.
Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
at dodge.keyPressed(dodge.java:152)
at java.awt.Component.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)

    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Sour

ce)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Sour
ce)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
at dodge.keyReleased(dodge.java:156)
at java.awt.Component.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)

    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Sour

ce)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Sour
ce)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
No se pudo cargar la imagen ship1.png de null
El error fue : java.lang.IllegalArgumentException input == null!

thanks in advance

Make sure that when you load your images and other resources in your program, you use the same name as the actual resource filename.

For example,

loadImage("ship1.png");

and your image is actually named ship1.PNG or some other variation.

This will work in your IDE, but it will not work when you try to run the actual jar file.

hey it worked. I just had to reaname the file and then recreate the jar file. It turns out that jars are cap sensitive and the IDE isnt.

The problem is Windows filesystem being case insensitive (kind of). While executing in the IDE, the build-directory is on the classpath, so your resources are loaded from the filesystem.