[問題] 在Linux上將BufferedImage儲存成JPEG圖檔

看板java作者 (hope)時間18年前 (2007/06/07 18:57), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/3 (看更多)
之前我為了一個網頁系統寫了一隻畫圖程式 但為了讓它可以在server上執行時可以將顯示畫面另存成圖檔 好讓使用者可以存取 所以我把它改成用BufferedImage 好不容易改成功了.在windows上可以成功執行 可是當我拿到Linux Server上測試的時候 它卻出現以下錯誤訊息 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:1 34) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:141) at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvi ronment.java:62) at java.awt.Window.init(Window.java:231) at java.awt.Window.<init>(Window.java:275) at java.awt.Frame.<init>(Frame.java:401) at EntropyPlot.<init>(EntropyPlot.java:40) at EntropyPlot.main(EntropyPlot.java:349) 看來好像是作業系統不同的問題 是因為我有用到BufferedImage.Graphics.Frame.Panel的關係嗎 請問這有什麼方法可以解決嗎? 因為我後來是著把Frame.Panel拿掉還是不行 還有我是用下面這個方法儲存圖檔的 FileOutputStream out = new FileOutputStream("C://Post.jpg"); com.sun.image.codec.jpeg.JPEGImageEncoder encoder = com.sun.image.codec.jpeg.JPEGCodec.createJPEGEncoder(out); encoder.encode(image); out.close(); 謝謝 -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.25.101.155
文章代碼(AID): #16P-I8WP (java)
文章代碼(AID): #16P-I8WP (java)