In my Linux computer,it can't save Image or Graphics to picture format such as png,jpg,tiff,pdf... but txt is OK
p=Graphics@Circle[];
Export["test.jpg",p];(*always calculating*)
I want to know is there something alternative way to save picture like using JLink?
System
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
I try this code but no image file found.
<< JLink`;
InstallJava[];
outputfile = JavaNew["java.io.File", "test.png"];
img = RandomImage[1, {20, 10}, ColorSpace -> "RGB"];
{h, w} = ImageDimensions[img];
src = JavaNew["java.awt.image.BufferedImage", w, h,BufferedImage`TYPEUINTURGB];
LoadJavaClass["javax.imageio.ImageIO"];
ImageIO@write[src, "PNG", outputfile]
Do I need install some package?
Update:
In my another Linux machine,it raise error.
Using romote kernel from mathematica,it's OK.
Thank you @Szabolcs.
sudo apt-get install xvfb
xvfb-run wolfram
Then it can export Graphics or Image!



Exportdoes not work on Linux? That will be a major bug if this was the case. But what doesDirectory[]say before you issue the command? – Nasser Oct 15 '17 at 05:44TimeConstrainedThis is expected. If operation do not complete in the time gives, it will abort.
So what you have to do, is remove the
– Nasser Oct 15 '17 at 06:23TimeConstrainedIt looks like it needs more than one second to do the export. Any reason why you are usingTimeConstrainedby the way? Here is an exampleTimeConstrained[NextPrime[1000], 0.0001]which gives$AbortedTimeConstrainedjust explained this problem, so I used that function.Even for ten minutes, it could not export it.I can't record gif for long time, so I used one second. – partida 32 mins ago – partida Oct 15 '17 at 07:03ssh -X/ssh -Yor use Xfvb. – Szabolcs Oct 15 '17 at 08:55sudo apt-get install xvfbthenxvfb-run wolfram,everything is OK!!! – partida Oct 16 '17 at 01:16