• Register
0 votes
91 views

Problem :

I am having following warning message.

The serializable class does not declare a static final serialversionuid field of type long

I would like to understand and resolve the issue. Can somebody explain me this issue with simple words? I know what OOPs is

Please find below my code for your reference :

import java.awt.*;
import javax.swing.*;
public class HelloSwing extends JFrame {
JTextArea m_resultArea = new JTextArea(6, 30);
public HelloSwing() {
//... Set initial text, scrolling, and border.
m_resultArea.setText("Enter some more text to see scrollbars");
JScrollPane scrollingArea = new JScrollPane(m_resultArea);
            scrollingArea.setBorder(BorderFactory.createEmptyBorder(10,5,10,5));
// Get the content pane, set layout, add to center
Container content = this.getContentPane();
content.setLayout(new BorderLayout());
content.add(scrollingArea, BorderLayout.CENTER);
this.pack();
        }
public static void createAndViewJFrame() {
JFrame win = new HelloSwing();
win.setTitle("TextAreaDemo");
            win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
win.setVisible(true);
}
     
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable(){
public void run(){
createAndViewJFrame();
                }
            });
        }
}
6 5 3
7,540 points

1 Answer

0 votes

Solution :

Please find below the solution on your problem :

You can configure your IDE in two ways:

·To ignore the error message instead of giving a warning.

·To auto generate an id

It can cause the problem only if you are serializing objects and deserializing them in a different place OR time where the class has changed, and it will not result in freezing, but in InvalidClassException

9 7 4
38,600 points

Related questions

0 votes
1 answer 369 views
369 views
Problem : I am trying to learn Java, I am very newbie however I wanted to know what I do to get the "run" it. I am facing below error: Static Error: This class does not have a static void main method accepting String[]. Below is my code: public class MyCaneirinho { public static void mycontar ... { System.out.println(j + x + y); } else { System.out.println(j + x + y + z); } } } } // MyCarneirinho
asked Dec 10, 2019 alecxe 7.5k points
0 votes
1 answer 38 views
38 views
Problem : In Java, I want to have something as below : class MyClazz<T> {  static void doIt(T object) {    // More code  } } But I face below error &ldquo;Cannot make a static reference to the non-static type T&rdquo; I am unable to understand ... about a subject. Could someone clarify if such the use is possible, by the similar manner? Also, why was my original attempt went unsuccessful?
asked Jan 21 jwilliam 3.9k points
0 votes
1 answer 8 views
8 views
Why static and final are not compatible together in Java ?
asked Sep 22 rm02 310 points
0 votes
1 answer 68 views
68 views
Problems:- Can any one help with one of the query I am facing in declaring variable type Declare a reference variable of type File named myFile. Any Idea
asked Feb 13 maddi86 5.4k points
0 votes
1 answer 13 views
13 views
Problem: You should not define a class field that is dependent upon the values of other class fields: A) in order to avoid having stale data B) because it is redundant C) because it should be defined in another class D) in order to keep it current
asked Aug 4 ArifulIslam 5.7k points