That will try to create the image in directory under the root directory of a Unix system.
If you're trying to create the image in the web application's directory you'll need to get the real path.
IMO, this is a bad idea: dynamically-created images shouldn't be created in the web app context, as they might be removed during a redeploy, etc. Create them in, and serve them from, a directory that's guaranteed to exist, and guaranteed to not be destroyed. Images outside of the application context can be served via a
servlet (or whatever back end technology you're using).