我的部分代码如下
String text = "哇哈哈";
String imageFile = "test.JPG";
String outimage = "out.jpg";
int x = 50;
int y = 50;
String fontColor = "000000";
int fontSize = 20;
String fontStyle = "";
String fontName = "宋体"; OutputStream output=new FileOutputStream(new File(outimage)); if(imageFile.toLowerCase().endsWith(".jpeg")||imageFile.toLowerCase().endsWith(".jpg"))
{
InputStream imageIn = new FileInputStream(new File(imageFile));
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(imageIn);
BufferedImage image = decoder.decodeAsBufferedImage();
Graphics g=image.getGraphics();但出现以下错误Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:125)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:140)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1041)
at java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1031)
at testpic.main(testpic.java:40)有人知道是什么原因吗?
String text = "哇哈哈";
String imageFile = "test.JPG";
String outimage = "out.jpg";
int x = 50;
int y = 50;
String fontColor = "000000";
int fontSize = 20;
String fontStyle = "";
String fontName = "宋体"; OutputStream output=new FileOutputStream(new File(outimage)); if(imageFile.toLowerCase().endsWith(".jpeg")||imageFile.toLowerCase().endsWith(".jpg"))
{
InputStream imageIn = new FileInputStream(new File(imageFile));
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(imageIn);
BufferedImage image = decoder.decodeAsBufferedImage();
Graphics g=image.getGraphics();但出现以下错误Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:125)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:140)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1041)
at java.awt.image.BufferedImage.getGraphics(BufferedImage.java:1031)
at testpic.main(testpic.java:40)有人知道是什么原因吗?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货