BufferedImage image = null;
try {
Workspace ws = workspaceFactory.newInstance();
String command = "random-seed 0 " + ws.previewCommands();
SimpleJobOwner owner = new SimpleJobOwner("ImageGenerator", ws.world().mainRNG, Observer.class);
ws.runCompiledCommands(owner, ws.compileCommands(command));
image = ws.exportView();
ws.dispose();
return image;
} catch(InterruptedException e) {
//headless.dispose method can potentially throw an InterruptedException