File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes java.io.NotSerializableException when overwrite the JTable data into .txt file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java.io.NotSerializableException when overwrite the JTable data into .txt file " Watch "java.io.NotSerializableException when overwrite the JTable data into .txt file " New topic
Author

java.io.NotSerializableException when overwrite the JTable data into .txt file

roger lim shau xiong
Greenhorn

Joined: Jan 08, 2009
Posts: 7
hi everyone

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.
but i dunno how to attach my .txt file with this forum
did anyone need the .txt file?

i had edit the code and make it simple for reading
this is the objectinput code



this is the objectoutput code

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37884
    
  22
Welcome to JavaRanch

Please show us which line the Exception occurred on. Don't know whether the text file is necessary or not. Sorry.

You will need to find every object which might be invoked on that line, and check whether it is null, which is that much more difficult with all the additional code from NetBeans.
roger lim shau xiong
Greenhorn

Joined: Jan 08, 2009
Posts: 7
hi, thank you for reply me
i cant find the line of the exception code.


i had /*...*/ some of the code that generate from the GUI netbean at following

Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8801
    
    5
intermediate level question


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
roger lim shau xiong
Greenhorn

Joined: Jan 08, 2009
Posts: 7
did anyone know how to attach the .txt file?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37884
    
  22
Bert Bates wrote:intermediate level question
It wasn't originally. It was about finding a NullPointerException.

roger lim shau xiong:Why have you changed the original posting? It was about NullPointerExceptions yesterday, not NotSerializableExceptions. Why are you quoting different code from yesterday? If you change the original posting the replies will turn to nonsense.

Why are you passing so many nulls? Are you initialising all those references to real objects?
roger lim shau xiong
Greenhorn

Joined: Jan 08, 2009
Posts: 7
yes i had changed it because i had update the latest coding
i had change the code which i had show at the first msg
and i had change the subject because i found that the first line of the exception should be the java.io.NotSerializableException
and nullpointer exception had show at the bottom of NotSerializableException
and sorry for this, i won't change the original posting next time

the nulls is only the object that created by netbean
i had try to fill it full with object but the problem still the same
sorry again for the unconvenient
roger lim shau xiong
Greenhorn

Joined: Jan 08, 2009
Posts: 7
i had found a new thing that when i just double click the cell without change any data inside the table
and click the button "Save". the same exception which is
java.io.NotSerializableException: java.lang.reflect.Constructor
will come out again.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37884
    
  22
When you serialize an object, every field of every class must be a primitive or implement the Serializable interface or be labelled transient. So go through all your classes and look at all their types and see whether they all implement Serializable. Many well-known classes, eg String, ArrayList, already implement Serializable, so look at all the other classes.
roger lim shau xiong
Greenhorn

Joined: Jan 08, 2009
Posts: 7
i had create another class to serialize it



and the outputstream i change to this


After this i click the save button
the java.io.NotSerializableException had been solve
but when i trying to read back the studio1.txt
it comes out another exception
Problem reading back table from file: studio1.txtjava.lang.ClassCastException: gui.Data
roger lim shau xiong
Greenhorn

Joined: Jan 08, 2009
Posts: 7
my problem had been solve since i create this class


but there is another problem after i save the table
after i save the table, i click the load button to load back,
the table just become empty ,its looks like load a empty object into the frame
can anybody help me with this problem?

i can save the JTable by this code


and i load the JTable by this code


after this my table become empty..just like a empty frame.
anybody help will be my very appreciate
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: java.io.NotSerializableException when overwrite the JTable data into .txt file
 
Similar Threads
PASSING DATA IN A JTable
JTable challenge
jtable
JTable serialization problem
Problems passing data into file from JTable