Java.io.NotSerializableException: sun.awt.image.BufferedImageGraphics2D

Hi all!
This problem is in relation to a very complex bean for data visualization which is jarred and bridged as an activex control.
I am able to create the activex control and embed it in a vb form. But when I try to run the application in vb I get the following message and the application does not start.
java.io.NotSerializableException: sun.awt.image.BufferedImageGraphics2D The bean has not used the class mentioned above anywhere. It uses the
Image
class though. I have used other beans, which use the same drawing techniques as the bean in question, as activex controls, with no errors.
What could be the problem?
tia
Shailesh
PS: the actual error dump is 1 page long I can send it by email on request.

Hello,
Have you implemented the Serializable Interface? I usually receive that error when I forgot to implement that interface. It is mandatory for a JavaBean to implement this interface.
As an example:
import java.io.Serializable;
public class SimpleBean implements Serializable
I hope it helps.
Antonio Castro

Similar Messages

  • Java.io.NotSerializableException: sun.java2d.SunGraphics2D

    Gentlemen,
    I cannot find the reason for the following error message and it is driving me mad ... :-)
    java.io.NotSerializableException: sun.java2d.SunGraphics2D
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1330)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1302)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1245)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1330)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1302)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1245)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
    at gui.PreProcessor.b_save_actionPerformed(PreProcessor.java:964)
    ..... abbreviated
    I can figure out the reason being that something inside the _Spline class is not serializable but I've checked everything and it seems fine. All custom classes implements Serializable.
    Is there anyone who can give me a hint on what to look for? Is the sun.java2d.SunGraphics2D connected to any Swing component?
    Your reply highly appreciated.
    /Jonas Forssell, Sweden
    Here follows the class which for some reason cannot be serialized.
    package j3d;
    import java.awt.*;
    import java.io.*;
    import java.util.Vector;
    import javax.swing.tree.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.table.*;
    import gui.*;
    * Creates a nurbcurve in the shape of a Pline
    * @author   Jonas Forssell, Yuriy Mikhaylovskiy
    public class _Spline extends _NurbCurve implements _Object, Serializable{
      private Vector points = new Vector();
      private JTable table;
      private DefaultTableModel tableModel;
      private JButton jButton1, jButton2, jButton3;
      private JComboBox jComboBox1;
      static String[] hdr = {"Points"};
      private String[] curvetype = {"Polyline","Quadratic","Cubical"};
       * Creates a new Pline. The parameters are:
       * @param points[]               Starting point (distance to center point sets radius)
       * @param color                    Color of the arc
       * @param element_type          element type to be used for the FE-mesh
       * @param element_material     element material to be used for the FE-mesh
       * @param element_diameter     diameter of the element in the mesh
      public _Spline(boolean add) {
        super(add);
        order = 1;
      protected void writeObject(ObjectOutputStream out)  throws IOException{
          super.writeObject(out);
          out.writeObject(points);
        protected void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException{
          super.readObject(in);
          points = (Vector)in.readObject();
      public void reset(){
          _Point p;
          int kl;
          // Inititalize
          // Generate the control points
          controlPoints = new _CtrlPoint[points.size()];
          for (int i=0; i<points.size(); i++) {
              p = (_Point)points.elementAt(i);
              controlPoints[i] = new _CtrlPoint(p.x, p.y, p.z,1.0f,Color.GRAY);
          // Generate the knots
          kl = controlPoints.length+order+1;
          knots = new float[kl];
          for (int i=0; i<=order; i++) {
              knots[i] = 0.0f;
              knots[kl-1-i] = 1.0f;
          for (int i=1; i < controlPoints.length-order; i++) {
              knots[order+i] = (float)(i)/(float)(controlPoints.length-order);
        // Generate geometry & mesh 
        super.reset();
      public String toString(){ return "Spline ID=" + Id;}
      public MutableTreeNode get_TreeNode(){
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(this);
        // Add unique data for the _Arc
        for (int i=0; i<points.size(); i++)
            node.add(((_Point)points.elementAt(i)).get_TreeNode());
        // Add mesh data from _NurbCurve
        node.add(super.get_TreeNode());
        return node;
      public JPanel getEditPanel(Canvas3D j3d, PreProcessor pp){
          this.J3D = j3d;
          this.PreP = pp;
          JPanel jPanel0 = new JPanel();
          JPanel jPanel1 = new JPanel();
          JPanel jPanel2 = new JPanel();
          JPanel jPanel3 = new JPanel();
          jComboBox1 = new JComboBox(curvetype);
          jButton1 = new JButton(add == true?"Add":"Update");
          jButton2 = new JButton("Add Point");
          jButton3 = new JButton("Delete");
          String[] tmp = new String[1];
          tableModel = new DefaultTableModel(hdr,0);
          table = new JTable(tableModel);
          for(int i=0; i<points.size(); i++) {
              tmp[0] = ((_Point)points.elementAt(i)).toString();
              tableModel.addRow(tmp);
          JPanel p = new JPanel(new BorderLayout());
          JPanel p1 = new JPanel(new BorderLayout());
          JScrollPane sp = new JScrollPane();
          sp.setPreferredSize(new Dimension(180, 200));
          // Add all geometry data
          jPanel0.setLayout(new BoxLayout(jPanel0, BoxLayout.Y_AXIS));
          jPanel0.add(sp);
               sp.getViewport().add(table, null);
          jPanel0.add(jPanel1);
               jPanel1.setLayout(new GridLayout(1,2));
          jPanel1.add(jButton2, null);
               jButton2.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(ActionEvent e) {
                jButton2_actionPerformed(e);
          jPanel1.add(jButton3, null);
               jButton3.addActionListener(new java.awt.event.ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                       jButton3_actionPerformed(e);
          jPanel0.add(jPanel3);
               jPanel3.setLayout(new GridLayout(1,2));
               jPanel3.add(new JLabel("Curve Type"));
               jPanel3.add(jComboBox1);
                    jComboBox1.setSelectedIndex(order-1);
          // Add all mesh data
          jPanel0.add(super.getEditPanel(j3d,pp));
          // Finally, the update button
          jPanel0.add(jPanel2);
            jPanel2.add(jButton1);
          jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                jButton1_actionPerformed(e);
          jPanel0.validate();
          return jPanel0;
      void jButton1_actionPerformed(ActionEvent e) {
          _Spline tmp = this;
          if(points.size() == 0) return;
          order = jComboBox1.getSelectedIndex()+1;
          tmp.update(e);
          tmp.reset();
          if(add == true) {
              try {
                tmp = (_Spline)this.clone();
                J3D.add3D(tmp);
              } catch (CloneNotSupportedException e1) {
                  e1.printStackTrace();
              tmp.add = false;
          J3D.tree_reset();
          J3D.view_reset();
          J3D.repaint();
      void jButton2_actionPerformed(ActionEvent e) {
          String[] tmp = new String[1];
          Object[] obj = J3D.getSelectedObjects3D();
          for (int i=0; i<obj.length; i++)
          if(obj[i] !=null && obj[i] instanceof _Point){
            points.add((_Point)obj);
    tmp[0] = obj[i].toString();
    tableModel.addRow(tmp);
    void jButton3_actionPerformed(ActionEvent e) {
    int index = -1;
    Object[] obj = J3D.getSelectedObjects3D();
    for (int i=0; i<obj.length; i++)
    if(obj[i]!=null && obj[i] instanceof _Point){
    index = points.indexOf(obj[i]);
    if (index >=0) {
    points.removeElementAt(index);
    tableModel.removeRow(index);

    I agree, it looks frustrating. Obviously the serialization process has found the non-serializable object during the traversal of the object graph, but its difficult to know where this is.
    Your class looks a bit "serialization-heavy", if you don't mind me saying. I avoid serializing anything to do with swing components and stick to collections and my own classes. Do you need to serialize these? If not, mark them transient. You can do this for all of them and then reintroduce into the serialized form one at a time to see which one causes the problem (just for curiosity).
    When the object is deserialized you will have to make the necessary arrangements to set up any members that you marked transient, as these will be null. You can do this is readObject, but on this subject, why are you writing out the points member explicitly? It will be written out anyway since there is nothing special about it.
    I don't know how familiar you are with the serialization package but its a sharp instrument that needs respect. I would advise reading the specification, if you haven't already done so.

  • Sun.awt.image.ToolkitImage

    Hi
    I'm integrating with a 3rd party package which delivers various images.
    These come in different objects, mostly BASE64DecoderStream and BufferedImage. But, GIF files are delivered as a ToolkitImage object.
    For the BufferedImage I do something like
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    ImageIO.write(image, "JPG", stream);and puts it in DB. I just can't figure out a way to do the same for ToolkitImage.
    My questions are:
    1. Is there a way to convert/cast the ToolkitImage so i can format/encode it and put it in DB, similar to the example above?
    2. Where is the API documentation for the internal classes in package "sun.awt.image"?
    Hope you experts can help me out here :)

    > Didn't know it could be casted to an Image.
    Do you know of any documentation on sun.awt.image in general?
    Why Developers Should Not Write Programs That Call 'sun' Packages
    The classes that Sun includes with the Java 2 SDK, Standard Edition, fall into package groups java.*, javax.*, org.* and sun.*. All but the sun.* packages are a standard part of the Java platform and will be supported into the future. In general, packages such as sun.*, that are outside of the Java platform, can be different across OS platforms (Solaris, Windows, Linux, Macintosh, etc.) and can change at any time without notice with SDK versions (1.2, 1.2.1, 1.2.3, etc). Programs that contain direct calls to the sun.* packages are not 100% Pure Java. In other words:
    The java.*, javax.* and org.* packages documented in the Java 2 Platform Standard Edition API Specification make up the official, supported, public interface.
    If a Java program directly calls only API in these packages, it will operate on all Java-compatible platforms, regardless of the underlying OS platform.
    The sun.* packages are not part of the supported, public interface.
    A Java program that directly calls into sun.* packages is not guaranteed to work on all Java-compatible platforms. In fact, such a program is not guaranteed to work even in future versions on the same platform.
    For these reasons, there is no documentation available for the sun.* classes. Platform-independence is one of the great advantages of developing in the Java programming language. Furthermore, Sun and our licensees of Java technology are committed to maintaining backward compatibility of the APIs for future versions of the Java platform. (Except for code that relies on serious bugs that we later fix.) This means that once your program is written, the class files will work in future releases.
    Each company that implements the Java platform will do so in their own private way. The classes in sun.* are present in the SDK to support the Sun implementation of the Java platform: the sun.* classes are what make the Java platform classes work "under the covers" for the Sun Java 2 SDK. These classes will not in general be present on another vendor's Java platform. If your Java program asks for a class "sun.package.Foo" by name, it may fail with ClassNotFoundError, and you will have lost a major advantage of developing in Java.
    Technically, nothing prevents your program from calling into sun.* by name. From one release to another, these classes may be removed, or they may be moved from one package to another, and it's fairly likely that their interface (method names and signatures) will change. (From the Sun point of view, since we are committed to maintaining the Java platform, we need to be able to change sun.* to refine and enhance the platform.) In this case, even if you are willing to run only on the Sun implementation, you run the risk of a new version of the implementation breaking your program.
    In general, writing java programs that rely on sun.* is risky: they are not portable, and are not supported.
    ~

  • Where is sun.awt.image.Image in Java5?

    Hello,
    I'm trying to compile a package using Java 5, which was before compiled with 1.4. I geth the error "sun.awt.image.Image cannot be resolved or is not a valid superclass".
    I found that class in 1.4.2, but not in 1.5. Is there an substitution for that?
    Regards,
    Kai

    Look in:
    java.awt.Image and java.awt.image for your needs and remember the sun.* packages are not guarenteed to be supported or be the same from version to version.

  • Where to download  "sun.awt.image.codec.JPEGImageDecoderImpl"/Windows

    Hello,
    I bought some Java API. These API uses com/sun/image/codec/jpeg/JPEGCodec.
    I found these clases in src.zip in java install directory.
    Then, this code has a source line
    "import sun.awt.image.codec.JPEGImageDecoderImpl;"
    Where can I find/downlad this class?
    (I work on Windows platform)

    This class is in rt.jar package
    which is in ur jre directory/lib
    Hope u got it!!
    Pradhip

  • Getting java.io.NotSerializableException: sun.management.MemoryPoolImpl

    Hi,
    While trying to get JVM Memory pool information of a remote computer ,am getting java.io.NotSerializableException. I used following method
    ManagementFactory.getMemoryPollMXBean().
    Please help me to solve these exception.
    java.io.NotSerializableException: sun.management.MemoryPoolImpl
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
    at java.util.ArrayList.writeObject(ArrayList.java:570)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
    at com.path.systemmanager.tunnelGate.TunnelServlet.doPost(TunnelServlet.java:38)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
    at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
    at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
    at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
    at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
    Thanks,
    Sreejith

    I agree, it looks frustrating. Obviously the serialization process has found the non-serializable object during the traversal of the object graph, but its difficult to know where this is.
    Your class looks a bit "serialization-heavy", if you don't mind me saying. I avoid serializing anything to do with swing components and stick to collections and my own classes. Do you need to serialize these? If not, mark them transient. You can do this for all of them and then reintroduce into the serialized form one at a time to see which one causes the problem (just for curiosity).
    When the object is deserialized you will have to make the necessary arrangements to set up any members that you marked transient, as these will be null. You can do this is readObject, but on this subject, why are you writing out the points member explicitly? It will be written out anyway since there is nothing special about it.
    I don't know how familiar you are with the serialization package but its a sharp instrument that needs respect. I would advise reading the specification, if you haven't already done so.

  • Java.io.NotSerializableException: java.awt.BasicStroke - really confusing

    I have a class Box which has two member Size and Location, both Serializable.
    Then I have several classes (e.g. Node) which extend Box.
    None of all the classes (Box, Size, Location and all extensions of Box e.g. Node) use BasicStroke. I commented out the import of BasicStroke in all classes that are Serializable, so it cannot be used anywhere.
    The problem is I use drag and drop, and when Box is also Serializable I get the following error when trying to drop:
    java.io.NotSerializableException: java.awt.BasicStroke
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
         at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
         at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1251)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
         at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
         at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:391)
         at java.util.Vector.writeObject(Vector.java:1018)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:917)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1339)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
         at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
         at sun.awt.datatransfer.TransferableProxy.getTransferData(TransferableProxy.java:66)
         at java.awt.dnd.DropTargetContext$TransferableProxy.getTransferData(DropTargetContext.java:359)
         at kfotobook.kgui.KPageViewer.getFlavorData(KPageViewer.java:767)
         at kfotobook.kgui.KPageViewer.getFlavorData(KPageViewer.java:750)
         at kfotobook.kgui.KPageViewer.drop(KPageViewer.java:791)
         at java.awt.dnd.DropTarget.drop(DropTarget.java:430)
         at sun.awt.dnd.SunDropTargetContextPeer.processDropMessage(SunDropTargetContextPeer.java:500)
         at sun.awt.dnd.SunDropTargetContextPeer.access$800(SunDropTargetContextPeer.java:53)
         at sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchDropEvent(SunDropTargetContextPeer.java:812)
         at sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchEvent(SunDropTargetContextPeer.java:736)
         at sun.awt.dnd.SunDropTargetEvent.dispatch(SunDropTargetEvent.java:29)
         at java.awt.Component.dispatchEventImpl(Component.java:3826)
         at java.awt.Container.dispatchEventImpl(Container.java:2024)
         at java.awt.Component.dispatchEvent(Component.java:3803)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
         at java.awt.LightweightDispatcher.processDropTargetEvent(Container.java:3963)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3817)
         at java.awt.Container.dispatchEventImpl(Container.java:2010)
         at java.awt.Window.dispatchEventImpl(Window.java:1774)
         at java.awt.Component.dispatchEvent(Component.java:3803)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    I do not know how to better describe the error, because I have no clue why BasicStrokes is tried to serialize at all. I am really confused, but perhaps somebody has seen something similar and can give a hint.
    Message was edited by:
    kudi

    Thanks for the hint. Actually I must say once more that I was too tired that I have overseen a memeber field because of bad code layout :-( I better went to sleep...
    But there is still something confusing, that is also the reason why I did not search for the fields in the right class.
    So I have a class Box and a class Node which extends Box. Node is the one which contains the evil AWT references. When I declare only Node as Serializable, it works. But when I also declare the super class Box as Serializable the error occured.
    In my opinion a Serializable sub class with a super class which does not implement Serializable does not make sence, but as an accident I did it. What is the semantic in such a case? (At least I know it could not serialize the sub class as expected...)
    Message was edited by:
    kudi

  • Sun.awt.* package

    hello
    i have a problem in finding sun.awt.* package on the net if anybody has it can you please send it to me . and also with instructions like how to set the class path and is it needed put the package in jdk or its ok to put it out side jsdk. please send me asap.
    as iam developing my own filechooser class thats why i need this package to compile my class.
    thank you
    regards

    hello nobody there to help me with my problem.
    actually i have overrided the class Jfilechooser using only basic packages with importing sun.awt.shell.* package but iam facing this errors can you please help me out of this problem.
    FileChooser.java:4: package sun.awt.shell does not exist
    import sun.awt.shell.*;
    ^
    FileChooser.java:162: cannot resolve symbol
    symbol : class ShellFolder
    location: class FileChooser
    ShellFolder getShellFolder(File f) {
    ^
    FileChooser.java:88: cannot resolve symbol
    symbol : class ShellFolder
    location: class FileChooser
    if (!(f instanceof ShellFolder)) {
    ^
    FileChooser.java:93: cannot resolve symbol
    symbol : variable ShellFolder
    location: class FileChooser
    f = ShellFolder.getShellFolder(f);
    ^
    FileChooser.java:130: cannot resolve symbol
    symbol : class ShellFolder
    location: class FileChooser
    if (f instanceof ShellFolder) {
    ^
    FileChooser.java:131: cannot resolve symbol
    symbol : class ShellFolder
    location: class FileChooser
    return ((ShellFolder)f).isFileSystem();
    ^
    FileChooser.java:140: cannot resolve symbol
    symbol : class ShellFolder
    location: class FileChooser
    ShellFolder sf = getShellFolder(dir);
    ^
    FileChooser.java:163: cannot resolve symbol
    symbol : class ShellFolder
    location: class FileChooser
    if (!(f instanceof ShellFolder)
    ^
    FileChooser.java:170: cannot resolve symbol
    symbol : variable ShellFolder
    location: class FileChooser
    return ShellFolder.getShellFolder(f);
    ^
    FileChooser.java:221: cannot resolve symbol
    symbol : variable ShellFolder
    location: class FileChooser
    return ShellFolder.isFileSystemRoot(dir);
    ^
    FileChooser.java:226: cannot resolve symbol
    symbol : variable ShellFolder
    location: class FileChooser
    File f = (File)ShellFolder.get("fileChooserDefaultFolder");
    thanks in advance
    regards

  • OutOfMemory error in java.awt.image.DataBufferInt. init

    We have an applet application that performs Print Preview of the images in the canvas. The images are like a network of entities (it has pictures of the entities involve (let's say Person) and how it links to other entities). We are using IE to launch the applet.
    We set min heap space to 128MB, JVM max heap space to 256MB, java plugin max heap space to 256MB using the Control Panel > Java.
    When the canvas width is about 54860 and height is 1644 and perform Print Preview, it thows an OutOfMemoryError in java.awt.image.DataBufferInt.<int>, hence, the Print Preview page is not shown. The complete stack trace (and logs) is as follows:
    Width: 54860 H: 1644
    Max heap: 254 # using Runtime.getRuntime().maxMemory()
    javaplugin.maxHeapSize: 256M # using System.getProperties("javaplugin.maxHeapSize")
    n page x n page : 1x1
    Exception in thread "AWT-EventQueue-2" java.lang.OutOfMemoryError: Java heap space
         at java.awt.image.DataBufferInt.<init>(Unknown Source)
         at java.awt.image.Raster.createPackedRaster(Unknown Source)
         at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
         at java.awt.image.BufferedImage.<init>(Unknown Source)
         at com.azeus.gdi.chart.GDIChart.preparePreview(GDIChart.java:731)
         at com.azeus.gdi.chart.GDIChart.getPreview(GDIChart.java:893)
         at com.azeus.gdi.ui.GDIUserInterface.printPreviewOp(GDIUserInterface.java:1526)
         at com.azeus.gdi.ui.GDIUserInterface$21.actionPerformed(GDIUserInterface.java:1438)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at javax.swing.JComponent.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    Drilling down the cause of the problem. The OutOfMemory occurred in the constructor of DataBufferInt when it tried to create an int array:
    public DataBufferInt(int size) {
    super(STABLE, TYPE_INT, size);
    data = new int[size]; # this part produce out of memory error when size = width X height
    bankdata = new int[1][];
    bankdata[0] = data;
    The OutOfMemory error occurred when size is width * height (54860 X 1644) which is 90,189,840 bytes (~86MB).
    I can replicate the OutOfMemory error when initiating an int array using a test class when it uses the default max heap space but if I increase the heap space to 256MB, it cannot be replicated in the test class.
    Using a smaller width and height with product not exceeding 64MB, the applet can perform Print Preview successfully.
    Given this, I think the java applet is not using the value assigned in javaplugin.maxHeapSize to set the max heap space, hence, it still uses the default max heap size and throws OutOfMemory in int array when size exceeds the default max heap space which is 64MB.
    For additional information, below is some of the java properties (when press S in java applet console):
    browser = sun.plugin
    browser.vendor = Sun Microsystems, Inc.
    browser.version = 1.1
    java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
    java.awt.printerjob = sun.awt.windows.WPrinterJob
    java.class.path = C:\PROGRA~1\Java\jre6\classes
    java.class.version = 50.0
    java.class.version.applet = true
    java.runtime.name = Java(TM) SE Runtime Environment
    java.runtime.version = 1.6.0_17-b04
    java.specification.version = 1.6
    java.vendor.applet = true
    java.version = 1.6.0_17
    java.version.applet = true
    javaplugin.maxHeapSpace = 256M
    javaplugin.nodotversion = 160_17
    javaplugin.version = 1.6.0_17
    javaplugin.vm.options = -Xms128M -Djavaplugin.maxHeapSpace=256M -Xmx256m -Xms128M
    javawebstart.version = javaws-1.6.0_17
    Kindly advise if this is a bug in JRE or wrong setting. If wrong setting, please advise on the proper way to set the heap space to prevent OutOfMemory in initializing int array.
    Thanks a lot.
    Edited by: rei_xanther on Jun 28, 2010 12:01 AM
    Edited by: rei_xanther on Jun 28, 2010 12:37 AM

    rei_xanther wrote:
    ..But the maximum value of the int data type is 2,147,483,647. That is the maximum positive integer value that can be stored in (the 4 bytes of) a signed int, but..
    ..The value that I passed in the int array size is only 90,189,840...its only connection with RAM is that each int requires 4 bytes of memory to hold it.
    new int[size] -- size is 90,189,840Sure. So the number of bytes required to hold those 90,189,840 ints is 360,759,360.
    I assumed that one element in the int array is 1 byte. ..Your assumption is wrong. How could it be possible to store 32 bits (4 bytes) in 8 bits (1 byte)? (a)
    a) Short of some clever compression algorithm applied to the data.

  • Useless code in java.awt.image.SampleModel.java?

    Hey there,
    i just looked up the sourcecode of java.awt.image.SampleModel.java in JDK 6
    I discovered two issues i'd like to discuss.
    1) on lines 736 to 739 this code is stated:
    if (iArray != null)
    pixels = iArray;
    else
    pixels = new int[numBands * w * h];
    I asked myself, why does this code exist? while the getPixels() method is overwritten twice by double[] getPixels() and float[] getPixels, it is impossible to reach the part of the java code that initializes the pixels-array. One could only step into that line if "null" is given for the i/d/fArray-parameter. but if one would do so, the Java parser couldn't determine, which method is to use. so this part of code is just useless IMHO.
    the java developers could get a little more performance out of this method if the if statement would be cut out - especially when reading a lot of very small rasters
    or, on the other hand, they could replace this piece of code by an explicit bounds check.
    When somebody touches this code, i would appreciate it if the errormessage "index out of bounds!" could be rewritten to be a little more verbose, like: Index out of bounds(x=123; y=456, maxX=100, maxY=400)!(numbers are just examples)
    I hope i didn't miss something very basic and could help improving this class a little bit.
    2) the local variable Offset(line 734) is coded against code conventions which say, variables shall start with a lowercase letter. Offset obviously doesn't fit that convention.
    best regards
    kdot

    One could only step into that line if "null" is given for the i/d/fArray-parameter. but if one would do so, the Java parser couldn't determine, which method is to use. so this part of code is just useless IMHO. You can have
    sampleModel.getPixels(x,y,w,h,(int[]) null, dataBuffer);No ambiguity on which method to use.
    the local variable Offset(line 734) is coded against code conventions which say, variables shall start with a lowercase letter. Offset obviously doesn't fit that convention. You're correct, offset is against coding conventions. So are many other examples scattered throughout the jdk source code. For example, Hashtable should be called HashTable. In some cases the coding conventions might not have been established when the original code was written. In other cases it might have been human error. In yet other cases the conventions were probably ignored. The person who wrote the SampleModel class did so some 10+ years ago (Java 1.2). Who knows what he/she was thinking at the time, and in all honesty - does it really matter in this case?
    Did you know there are some classes that declare unused local variables (ahem ColorConvertOp)? Some also have unused imports ( *** cough *** BufferedImage *** cough *** ). In essence, the jdk source code is not the epidemy of code correctness. But it's still pretty good.

  • How can I create a java.awt.Image from ...

    Hi all,
    How can I create a java.awt.Image from a drawing on a JPanel?
    Thanks.

    JPanel p;
    BufferedImage image =
        new BufferedImage(p.getWidth(), p.getHeight, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = image.createGraphics();
    p.paint(g);
    g.dispose();

  • Java.io.NotSerializableException: java.awt.AWTEventMulticaster

    I have an Applet. When I try to use the "print" feature on IE to print out the applet. I'm getting this Exception. java.io.NotSerializableException: java.awt.AWTEventMulticaster
    What should I do?
    Andy

    please help!!

  • Java.io.NotSerializableException: com.sun.xml.tree.XmlDocument

    Hi,
    I got this error when my servlet is trying to parse a xml document:
    RuntimeRemoteException( java.io.WriteAbortedException: Writing aborted by exception; java.io.NotSerializableException: com.sun.xml.tree.XmlDocument )
    And my application runs ok when Tomcat is used as servlet container, but it runs into problem when iPlanet is used.
    Any idea?
    Thanks in advance!

    Thanks for your reply.
    The EJBs in the application are all stateless beans. The error happens at the servlet side, not the EJB side. When the servlet tries to parse the returned XML document using xalan 1.0, the error happened. However, I can not reproduce the error when I use Tomcat as servlet container.
    here is how I coded:
    XSLTProcessor processor = XSLTProcessorFactory.getProcessor(new org.apache.xalan.xpath.xdom.XercesLiaison());
    XSLTInputSource xmlSource = new XSLTInputSource(doc);
    XSLTInputSource xslSheet = new XSLTInputSource("file:"+xslFile);
    Writer out = new StringWriter();
    XSLTResultTarget xmlResult= new XSLTResultTarget(out);
    processor.process(xmlSource,xslSheet,xmlResult);

  • Java.io.NotSerializableException when overwrite the JTable data into .txt file

    hi everyone
    this is my first time to get help from sun forums
    i had java.io.NotSerializableException: java.lang.reflect.Constructor error when overwrite the JTable data into .txt file.
    At the beginning, the code will be generate successfully and the jtable will be showing out with the data that been save in the studio1.txt previously,
    but after i edit the data at the JTable, and when i trying to click the save button, the error had been showing out and i cannot succeed to save the JTable with the latest data.
    After this error, the code can't be run again and i had to copy the studio1.txt again to let the code run 1 more time.
    I hope i can get any solution at here and this will be very useful for me.
    the following is my code...some of it i create it with the GUI netbean
    but i dunno how to attach my .txt file with this forum
    did anyone need the .txt file?
    this is the code that suspect maybe some error here
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    String filename = "studio1.txt";
              try {
                  FileOutputStream fos = new FileOutputStream(new File(filename));
                  ObjectOutputStream oos = new ObjectOutputStream(fos);
                   oos.writeObject(jTable2);
                   oos.close();
              catch(IOException e) {
                   System.out.println("Problem creating table file: " + e);
                   return;
              System.out.println("JTable correctly saved to file " + filename);
    }the full code will be at the next msg

    this is the part 1 of the code
    this is the full code...i had /*....*/ some of it to make it easier for reading
    package gui;
    import javax.swing.*;
    import java.io.*;
    public class timetables extends javax.swing.JFrame {
        public timetables() {
            initComponents();
        @SuppressWarnings("unchecked")
        private void initComponents() {
            jDialog1 = new javax.swing.JDialog();
            buttonGroup1 = new javax.swing.ButtonGroup();
            buttonGroup2 = new javax.swing.ButtonGroup();
            buttonGroup3 = new javax.swing.ButtonGroup();
            buttonGroup4 = new javax.swing.ButtonGroup();
            jTextField1 = new javax.swing.JTextField();
            jLayeredPane1 = new javax.swing.JLayeredPane();
            jLabel6 = new javax.swing.JLabel();
            jTabbedPane1 = new javax.swing.JTabbedPane();
            jScrollPane3 = new javax.swing.JScrollPane();
            jTable2 = new javax.swing.JTable();
            jScrollPane4 = new javax.swing.JScrollPane();
            jTable3 = new javax.swing.JTable();
            jButton1 = new javax.swing.JButton();
            jButton2 = new javax.swing.JButton();
    /*       org.jdesktop.layout.GroupLayout jDialog1Layout = new org.jdesktop.layout.GroupLayout(jDialog1.getContentPane());
            jDialog1.getContentPane().setLayout(jDialog1Layout);
            jDialog1Layout.setHorizontalGroup(
                jDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 400, Short.MAX_VALUE)
            jDialog1Layout.setVerticalGroup(
                jDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 300, Short.MAX_VALUE)
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jLayeredPane1.add(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);
            String filename1 = "studio1.txt";
            try {
                   ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filename1));
                   jTable2 = (JTable) ois.readObject();
                   System.out.println("reading for " + filename1);
              catch(Exception e) {
                   System.out.println("Problem reading back table from file: " + filename1);
                   return;
            try {
                   ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filename1));
                   jTable3 = (JTable) ois.readObject();
                   System.out.println("reading for " + filename1);
              catch(Exception e) {
                   System.out.println("Problem reading back table from file: " + filename1);
                   return;
            jTable2.setRowHeight(20);
            jTable3.setRowHeight(20);
            jScrollPane3.setViewportView(jTable2);
            jScrollPane4.setViewportView(jTable3);
            jTable2.getColumnModel().getColumn(4).setResizable(false);
            jTable3.getColumnModel().getColumn(4).setResizable(false);
            jTabbedPane1.addTab("STUDIO 1", jScrollPane3);
            jTabbedPane1.addTab("STUDIO 2", jScrollPane4);
            jTextField1.setText("again n again");
            jLabel6.setText("jLabel5");
            jLabel6.setBounds(0, 0, -1, -1);
            jButton2.setText("jButton2");
            jButton1.setText("jButton1");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
          

  • Question : Save AWT Image Class to File..

    I Have a Question.. @.@a
    I'm doing AWT transform now..
    Well...
    I have a problem..
    I want to save AWT Image class to file..
    But.. I don't now that..
    Input Image Class same below..
    Image imageContent = (Image)attachment.getContent();
    How does it save imageContent Image class to file..?

    I had the same problem... convert it to a BufferedImage (http://forum.java.sun.com/thread.jspa?threadID=665744&tstart=15), then use javax.imageio.ImageIO.write to save it to a file.

Maybe you are looking for

  • Data Quality - Failed to create connection to MDR.

    Hi All, I have installed Data Quality 11.7.2 on windows 2003 server using SQL 2005 (Both SQL 2005 server and Data Quality are in the same server) , The install was successful. But when I try to Open 'Data Quality Project Architect' it throws an error

  • C3-01: Strange Bluetooth behaviour

    I tried to connect my Bluetooth Headset with my c3-01. It worked, but in the first moment, the sounds only appeared on the left ear. I tried with different sounds, everytime the same. So I thought, the headset would be damaged - I did a crosscheck wi

  • When menu bar is hidden, I cannot find the Tools option (and i.e. Session Manager plug-in options)

    The new look where the menu bar is hidden, looks really nice. ...but I can't find the Tools option when the menu bar is hidden. Therefore I can't access plug-in options like Session Manager. I would really like the Tools menu appearing i.e. below the

  • Mail won't show up

    After the upgarde on my iMac 27" retina I see all mail's notifications but when I try to open Mail nothing happens: all is trasparent. The only thing I can see are the borders of the window, nothing more. It's the only application that is giving me p

  • Mavericks and Disk Doctor

    I am selling my iMac.  So to keep my personal data personal I erased it from the Imac and started Disk Doctor.  Then 1. I ran DD and did a Repair Permissions 2. I ran Erase Disk Well I started running Erase Disk.  It ran all night and was still runni