本地方法出错,是不是linux中java的图形编程要依附于kde或者gnome呀,没做过linux下面的,
网上应该有这方面的东西。

解决方案 »

  1.   

    请教楼上兄弟,上面都是调用系统函数的,而且在windows下可以运行啊
      

  2.   

    我没在linux上写过程序,不是很清楚,但是印象中好像决的需要本地的图形库才可以运行图像处理的api,下面是sun网站上的一个faq,你看看。必须要Xserver支持,即使你没有显示图像。I am writing an application that runs as a server process and it needs to read, write and process images, but there's no need to display them, but I find that when I run my application on Solaris or Linux it needs an Xserver. What's the problem and what can I do about it?A  The problem is in the implementation of the AWT toolkit. When its initialized it expects to find an Xserver, regardless of whether its needed for actual display. Although many image operations using the 1.4 Image I/O APIS (javax.imageio), the JAI optional package, or the non-standard com.sun.jpeg.codec classes might not have any obvious need for display, they often invoke code that needs an AWT toolkit resource. For example, calling getGraphics on a BufferedImage initializes AWT and causes the problem seen by developers. There's no way to say that a particular API does or doesn't have this problem; it depends on what particular operations are being invoked, and might also depend on what the application does with the images that isn't strictly related to any of the APIs cited above. There are two possible solutions. For releases prior to 1.4 you can provide a "pseudo X-server" to emulate a display environment One of these X-server emulators is Xvfb, available for download at www.x.org. The preferred solution for release 1.4 and later is to use the new headless AWT toolkit. This new feature allows you to use the J2SE API in a server-side Java application without requiring you to have a GUI environment. To specify the headless environment when using Sun Microsystem's reference implementation, run your application with this property:     -Djava.awt.headless=true If your application isn't a client application, meaning that it doesn't involve user interaction, then this mode of operation should probably always be used. 
    Xvfb does still have one possible use in 1.4: A server application does display to an Xserver, but requires no user interaction. The headless toolkit won't support this situation, but xvfb will. This is a completely hypothetical scenario and it is not clear if any real world application exhibits such a behaviour.
      

  3.   

    Linux下让tomcat显示图片(jdk1.4, tomcat4.0 或更高版本) 
    http://blog.csdn.net/cm4ever/archive/2004/09/22/113145.aspx如果是运行类的话,加无头支持的参数java -Djava.awt.headless=true MyDrawPicture