• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

swing application problem

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

My all the images that are used in my game are in the same folder

where my jar file is present, so when i run my executable jar file

outside the reach of that folder than images does not get displayed

on my game, I mean when jar file is located inside the folder with

the images then images get displayed but if i move my jar file to

some other location then images doesn't get displayed.

I have included image inside my executable jar file but same

problem arises. I have attached the manifest file, source java file and

image also. The jar file also contains the image inside it. I have

not attached the whole game as it would have been difficult for you

to go through it. I have just given a part of it.

Manifest file:
Manifest-Version: 1.0
Created-By: 1.2 (Sun Microsystems Inc.)
Sealed: true
contentTypes: image/gif
Main-Class: test

Java source file:
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you package resources inside a jar file, you need to retrieve them in a different way.
Check out Class#getResource() and Class#getResourceAsStream() methods.

Also, checkout JFrame#setDefaultCloseOperation(). If you specify EXIT_ON_CLOSE, you really do not need to use the window listener.

Since this problem is not exactly gaming specific, I am moving this thread to a more appropriate forum for you.
 
rakesh kadulkar
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem has not yet benn solved.

I have tried both the things but now i am not even getting the image on the frame even though the image is in the directory as well as in the the executable jar fiel.

 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you show us your directory structure?
Also can you show us the code how you are loading the images?

Sometimes, on Windows, the system renames the files from jpg to JPG. This is also a know issue for images not loading. Can you confirm the case defined in your code and the case of the actual image matches?
 
rakesh kadulkar
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My directory structure:

test.jar
|
META-INF, images,test.class,test$1.class
| |
manifest.mf BlackJack.GIF

The contecnts of manifest file


The contents of test.java file
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will repeat what I recommended earlier

Maneesh Godbole wrote:When you package resources inside a jar file, you need to retrieve them in a different way.
Check out Class#getResource() and Class#getResourceAsStream() methods.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check the CASE sensitivity of the image file name including with extension.
Give the same string as given to file name.
reply
    Bookmark Topic Watch Topic
  • New Topic