This site requires JavaScript, please enable it in your browser!
Greenfoot back
danpost
danpost wrote ...

2012/1/22

Problem with stand-alone Jar export file

danpost danpost

2012/1/22

#
I do not know if I had created any stand-alone Jar files since the last update in Greenfoot, but I had written a new scenario with a world size of 500 x 600 x 1 and exported it as 'Application'. When I double click the new Jar file, all I get is a small world window of about 10 pixels high and only wide enough for the two buttons underneath (Reset and Run). Has anyone else had a problem like this before? or, does anyone have any idea what might be going on, and how to fix it?
davmac davmac

2012/1/22

#
Probably getting an exception when trying to construct the world. Run it from a terminal to get the stack trace (or send it to me, davmac, at greenfoot dot org, and I'll do that for you).
danpost danpost

2012/1/22

#
Yeah. I think I know what it is. I need the external files in the same directory as the jar, do I not?
danpost danpost

2012/1/22

#
I copied the image folder to where the jar file was and it worked!! :+) Thanks, davmac
davmac davmac

2012/1/22

#
If the images were in the scenario, they should have been included in the jar automatically. Was this not the case?
danpost danpost

2012/1/22

#
These were not object images, but user pictures, in which the directory is read programmatically. The scenario allows the user to insert the pictures into frames, adjust size and position, and save the array of pics as one image in a PNG file.
davmac davmac

2012/1/22

#
Ok, that's good - a clear case of needing to have them present alongside the jar file, then.
danpost danpost

2012/1/27

#
@davmac, is there an easy way to redirect what directory image files come from, programatically? It appears that if I change the images in the external folder, Greenfoot will not access them from the jar. It is evidently still using the "images" folder that was included when creating the jar.
davmac davmac

2012/1/28

#
I'm not sure I fully understand the question, but, from the GreenfootImage constructor documentation: The file name may be an absolute path, or a base name for a file located in the project directory. Essentially, when you load an image, Greenfoot looks first in the project (i.e. in the jar file). If it can't find the image there then it interprets the filename as a file path. If you don't want it to load the image from the jar file then you should remove the image from the jar file. You could also convert the filename to an absolute path (see the 'java.io.File' documentation in the JDK documentation) to prevent the resource in the jar file from being found.
danpost danpost

2012/1/28

#
I believe that answers my question; that is, one cannot redirect where the images are from -- you have to explicitly specify the path each time it is not from the 'images' folder (project directory).
You need to login to post a reply.