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;
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.
java bluej
marked as duplicate by Mark Rotteveel
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.
|
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.
java bluej
marked as duplicate by Mark Rotteveel
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 usingObjectOutputStream
at all.
– Mark Rotteveel
Mar 9 at 5:24
|
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.
java bluej
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
java bluej
asked Mar 9 at 4:36
Juan NavarroJuan Navarro
1
1
marked as duplicate by Mark Rotteveel
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
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 usingObjectOutputStream
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 usingObjectOutputStream
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
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.
ApplyingtoString
with anObjectOutputStream
is not the right approach, because it will not be possible to obtain the same type of object from theObjectInputStream
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
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.
ApplyingtoString
with anObjectOutputStream
is not the right approach, because it will not be possible to obtain the same type of object from theObjectInputStream
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
|
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.
ApplyingtoString
with anObjectOutputStream
is not the right approach, because it will not be possible to obtain the same type of object from theObjectInputStream
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
|
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.
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.
answered Mar 9 at 5:06
mtumtu
163
163
ApplyingtoString
with anObjectOutputStream
is not the right approach, because it will not be possible to obtain the same type of object from theObjectInputStream
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
|
ApplyingtoString
with anObjectOutputStream
is not the right approach, because it will not be possible to obtain the same type of object from theObjectInputStream
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
|
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