Why do I get java.io.NotSerializableException [duplicate] The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceNotSerializableException on saving custom classI keep getting java.io.NotSerializableException: java.io.ObjectOutputStreamWhat is reflection and why is it useful?Does a finally block always get executed in Java?What is a serialVersionUID and why should I use it?How to get an enum value from a string value in Java?Why is subtracting these two times (in 1927) giving a strange result?Why don't Java's +=, -=, *=, /= compound assignment operators require casting?Why is char[] preferred over String for passwords?Why is it faster to process a sorted array than an unsorted array?Can't start Eclipse - Java was started but returned exit code=13Why is printing “B” dramatically slower than printing “#”?

Like totally amazing interchangeable sister outfit accessory swapping or whatever

Preserving file and folder permissions with rsync

Has a Nobel Peace laureate ever been accused of war crimes?

When speaking, how do you change your mind mid-sentence?

What's the difference between using dependency injection with a container and using a service locator?

TV series episode where humans nuke aliens before decrypting their message that states they come in peace

What is ls Largest Number Formed by only moving two sticks in 508?

Specify the range of GridLines

Is there a possibility to generate a list dynamically in Latex?

How was Lagrange appointed professor of mathematics so early?

Determinant of a matrix with 2 equal rows

Is Bran literally the world's memory?

Was there ever a LEGO store in Miami International Airport?

`FindRoot [ ]`::jsing: Encountered a singular Jacobian at a point...WHY

Feather, the Redeemed and Dire Fleet Daredevil

How would you suggest I follow up with coworkers about our deadline that's today?

How can I wire a 9-position switch so that each position turns on one more LED than the one before?

How to begin with a paragraph in latex

Is it accepted to use working hours to read general interest books?

SQL Server placement of master database files vs resource database files

All ASCII characters with a given bit count

What were wait-states, and why was it only an issue for PCs?

Simulate round-robin tournament draw

What do you call an IPA symbol that lacks a name (e.g. ɲ)?



Why do I get java.io.NotSerializableException [duplicate]



The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceNotSerializableException on saving custom classI keep getting java.io.NotSerializableException: java.io.ObjectOutputStreamWhat is reflection and why is it useful?Does a finally block always get executed in Java?What is a serialVersionUID and why should I use it?How to get an enum value from a string value in Java?Why is subtracting these two times (in 1927) giving a strange result?Why don't Java's +=, -=, *=, /= compound assignment operators require casting?Why is char[] preferred over String for passwords?Why is it faster to process a sorted array than an unsorted array?Can't start Eclipse - Java was started but returned exit code=13Why is printing “B” dramatically slower than printing “#”?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-2
















This question already has an answer here:



  • NotSerializableException on saving custom class

    3 answers



I have a program in which I have appointments which are stored inside days which are stored inside weeks. Appointments, days and Weeks are all classes. I try to doout.writeObject(Week1); in my GUI and it compiles but it comes out as not serializable.
I'm sorry if this seems obvious to some of you but I have not serialized before.









share













marked as duplicate by Mark Rotteveel java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 9 at 5:21


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • 1





    put your code and error message

    – Jahirul Islam Bhuiyan
    Mar 9 at 4:40











  • ObjectOutputStream.writeObject and NotSerializableException should be sufficient documentation.

    – ernest_k
    Mar 9 at 4:41











  • try FileOutputStream fileOut = new FileOutputStream("data.txt"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(Week1); out.close(); fileOut.close(); System.out.println("Serialized data is saved in data.txt"); catch (IOException i) i.printStackTrace(); }

    – Juan Navarro
    Mar 9 at 4:42











  • This is inside an actionListener in my GUI

    – Juan Navarro
    Mar 9 at 4:42











  • You should carefully consider if you should be using ObjectOutputStream at all.

    – Mark Rotteveel
    Mar 9 at 5:24

















-2
















This question already has an answer here:



  • NotSerializableException on saving custom class

    3 answers



I have a program in which I have appointments which are stored inside days which are stored inside weeks. Appointments, days and Weeks are all classes. I try to doout.writeObject(Week1); in my GUI and it compiles but it comes out as not serializable.
I'm sorry if this seems obvious to some of you but I have not serialized before.









share













marked as duplicate by Mark Rotteveel java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 9 at 5:21


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • 1





    put your code and error message

    – Jahirul Islam Bhuiyan
    Mar 9 at 4:40











  • ObjectOutputStream.writeObject and NotSerializableException should be sufficient documentation.

    – ernest_k
    Mar 9 at 4:41











  • try FileOutputStream fileOut = new FileOutputStream("data.txt"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(Week1); out.close(); fileOut.close(); System.out.println("Serialized data is saved in data.txt"); catch (IOException i) i.printStackTrace(); }

    – Juan Navarro
    Mar 9 at 4:42











  • This is inside an actionListener in my GUI

    – Juan Navarro
    Mar 9 at 4:42











  • You should carefully consider if you should be using ObjectOutputStream at all.

    – Mark Rotteveel
    Mar 9 at 5:24













-2












-2








-2









This question already has an answer here:



  • NotSerializableException on saving custom class

    3 answers



I have a program in which I have appointments which are stored inside days which are stored inside weeks. Appointments, days and Weeks are all classes. I try to doout.writeObject(Week1); in my GUI and it compiles but it comes out as not serializable.
I'm sorry if this seems obvious to some of you but I have not serialized before.









share















This question already has an answer here:



  • NotSerializableException on saving custom class

    3 answers



I have a program in which I have appointments which are stored inside days which are stored inside weeks. Appointments, days and Weeks are all classes. I try to doout.writeObject(Week1); in my GUI and it compiles but it comes out as not serializable.
I'm sorry if this seems obvious to some of you but I have not serialized before.





This question already has an answer here:



  • NotSerializableException on saving custom class

    3 answers







java bluej





share












share










share



share










asked Mar 9 at 4:36









Juan NavarroJuan Navarro

1




1




marked as duplicate by Mark Rotteveel java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 9 at 5:21


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Mark Rotteveel java
Users with the  java badge can single-handedly close java questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Mar 9 at 5:21


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 1





    put your code and error message

    – Jahirul Islam Bhuiyan
    Mar 9 at 4:40











  • ObjectOutputStream.writeObject and NotSerializableException should be sufficient documentation.

    – ernest_k
    Mar 9 at 4:41











  • try FileOutputStream fileOut = new FileOutputStream("data.txt"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(Week1); out.close(); fileOut.close(); System.out.println("Serialized data is saved in data.txt"); catch (IOException i) i.printStackTrace(); }

    – Juan Navarro
    Mar 9 at 4:42











  • This is inside an actionListener in my GUI

    – Juan Navarro
    Mar 9 at 4:42











  • You should carefully consider if you should be using ObjectOutputStream at all.

    – Mark Rotteveel
    Mar 9 at 5:24












  • 1





    put your code and error message

    – Jahirul Islam Bhuiyan
    Mar 9 at 4:40











  • ObjectOutputStream.writeObject and NotSerializableException should be sufficient documentation.

    – ernest_k
    Mar 9 at 4:41











  • try FileOutputStream fileOut = new FileOutputStream("data.txt"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(Week1); out.close(); fileOut.close(); System.out.println("Serialized data is saved in data.txt"); catch (IOException i) i.printStackTrace(); }

    – Juan Navarro
    Mar 9 at 4:42











  • This is inside an actionListener in my GUI

    – Juan Navarro
    Mar 9 at 4:42











  • You should carefully consider if you should be using ObjectOutputStream at all.

    – Mark Rotteveel
    Mar 9 at 5:24







1




1





put your code and error message

– Jahirul Islam Bhuiyan
Mar 9 at 4:40





put your code and error message

– Jahirul Islam Bhuiyan
Mar 9 at 4:40













ObjectOutputStream.writeObject and NotSerializableException should be sufficient documentation.

– ernest_k
Mar 9 at 4:41





ObjectOutputStream.writeObject and NotSerializableException should be sufficient documentation.

– ernest_k
Mar 9 at 4:41













try FileOutputStream fileOut = new FileOutputStream("data.txt"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(Week1); out.close(); fileOut.close(); System.out.println("Serialized data is saved in data.txt"); catch (IOException i) i.printStackTrace(); }

– Juan Navarro
Mar 9 at 4:42





try FileOutputStream fileOut = new FileOutputStream("data.txt"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(Week1); out.close(); fileOut.close(); System.out.println("Serialized data is saved in data.txt"); catch (IOException i) i.printStackTrace(); }

– Juan Navarro
Mar 9 at 4:42













This is inside an actionListener in my GUI

– Juan Navarro
Mar 9 at 4:42





This is inside an actionListener in my GUI

– Juan Navarro
Mar 9 at 4:42













You should carefully consider if you should be using ObjectOutputStream at all.

– Mark Rotteveel
Mar 9 at 5:24





You should carefully consider if you should be using ObjectOutputStream at all.

– Mark Rotteveel
Mar 9 at 5:24












1 Answer
1






active

oldest

votes


















-1














You need to put more details such as your code and full stack trace of your error. Nobody knows what is your "out". In this case, I guess it is an ObjectOutputStream.



You need to know when you want to transmit an object through a network, wire, etc ... Your object must follow some kind of standard for it to serialize your data into bytes stream. All the default java.lang object has followed that standard, like String, Integer, Double, etc ... Therefore, when you wanna transmit those data, you don't have to do anything extra.



Because your custom object does not implement the java.io.Serializable interface (the standard I mentioned), it can't be serialized into a bytes stream. So, you may wanna implement that interface or override the toString() method and call out.writeObject(Week1.toString()) I guess.





share























  • Applying toString with an ObjectOutputStream is not the right approach, because it will not be possible to obtain the same type of object from the ObjectInputStream again.

    – Mark Rotteveel
    Mar 9 at 5:24











  • @MarkRotteveel I know it's not a good choice. I'm just listing the options.

    – mtu
    Mar 10 at 3:26


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









-1














You need to put more details such as your code and full stack trace of your error. Nobody knows what is your "out". In this case, I guess it is an ObjectOutputStream.



You need to know when you want to transmit an object through a network, wire, etc ... Your object must follow some kind of standard for it to serialize your data into bytes stream. All the default java.lang object has followed that standard, like String, Integer, Double, etc ... Therefore, when you wanna transmit those data, you don't have to do anything extra.



Because your custom object does not implement the java.io.Serializable interface (the standard I mentioned), it can't be serialized into a bytes stream. So, you may wanna implement that interface or override the toString() method and call out.writeObject(Week1.toString()) I guess.





share























  • Applying toString with an ObjectOutputStream is not the right approach, because it will not be possible to obtain the same type of object from the ObjectInputStream again.

    – Mark Rotteveel
    Mar 9 at 5:24











  • @MarkRotteveel I know it's not a good choice. I'm just listing the options.

    – mtu
    Mar 10 at 3:26















-1














You need to put more details such as your code and full stack trace of your error. Nobody knows what is your "out". In this case, I guess it is an ObjectOutputStream.



You need to know when you want to transmit an object through a network, wire, etc ... Your object must follow some kind of standard for it to serialize your data into bytes stream. All the default java.lang object has followed that standard, like String, Integer, Double, etc ... Therefore, when you wanna transmit those data, you don't have to do anything extra.



Because your custom object does not implement the java.io.Serializable interface (the standard I mentioned), it can't be serialized into a bytes stream. So, you may wanna implement that interface or override the toString() method and call out.writeObject(Week1.toString()) I guess.





share























  • Applying toString with an ObjectOutputStream is not the right approach, because it will not be possible to obtain the same type of object from the ObjectInputStream again.

    – Mark Rotteveel
    Mar 9 at 5:24











  • @MarkRotteveel I know it's not a good choice. I'm just listing the options.

    – mtu
    Mar 10 at 3:26













-1












-1








-1







You need to put more details such as your code and full stack trace of your error. Nobody knows what is your "out". In this case, I guess it is an ObjectOutputStream.



You need to know when you want to transmit an object through a network, wire, etc ... Your object must follow some kind of standard for it to serialize your data into bytes stream. All the default java.lang object has followed that standard, like String, Integer, Double, etc ... Therefore, when you wanna transmit those data, you don't have to do anything extra.



Because your custom object does not implement the java.io.Serializable interface (the standard I mentioned), it can't be serialized into a bytes stream. So, you may wanna implement that interface or override the toString() method and call out.writeObject(Week1.toString()) I guess.





share













You need to put more details such as your code and full stack trace of your error. Nobody knows what is your "out". In this case, I guess it is an ObjectOutputStream.



You need to know when you want to transmit an object through a network, wire, etc ... Your object must follow some kind of standard for it to serialize your data into bytes stream. All the default java.lang object has followed that standard, like String, Integer, Double, etc ... Therefore, when you wanna transmit those data, you don't have to do anything extra.



Because your custom object does not implement the java.io.Serializable interface (the standard I mentioned), it can't be serialized into a bytes stream. So, you may wanna implement that interface or override the toString() method and call out.writeObject(Week1.toString()) I guess.






share











share


share










answered Mar 9 at 5:06









mtumtu

163




163












  • Applying toString with an ObjectOutputStream is not the right approach, because it will not be possible to obtain the same type of object from the ObjectInputStream again.

    – Mark Rotteveel
    Mar 9 at 5:24











  • @MarkRotteveel I know it's not a good choice. I'm just listing the options.

    – mtu
    Mar 10 at 3:26

















  • Applying toString with an ObjectOutputStream is not the right approach, because it will not be possible to obtain the same type of object from the ObjectInputStream again.

    – Mark Rotteveel
    Mar 9 at 5:24











  • @MarkRotteveel I know it's not a good choice. I'm just listing the options.

    – mtu
    Mar 10 at 3:26
















Applying toString with an ObjectOutputStream is not the right approach, because it will not be possible to obtain the same type of object from the ObjectInputStream again.

– Mark Rotteveel
Mar 9 at 5:24





Applying toString with an ObjectOutputStream is not the right approach, because it will not be possible to obtain the same type of object from the ObjectInputStream again.

– Mark Rotteveel
Mar 9 at 5:24













@MarkRotteveel I know it's not a good choice. I'm just listing the options.

– mtu
Mar 10 at 3:26





@MarkRotteveel I know it's not a good choice. I'm just listing the options.

– mtu
Mar 10 at 3:26





Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved