5 Replies - 1893 Views - Last Post: 07 October 2010 - 02:41 PM Rate Topic: -----

#1 Kurplepush   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 78
  • Joined: 08-March 10

Warning Error Serializable Class

Posted 07 October 2010 - 01:54 PM

Im getting the following Error when executing my program:
[email protected]:~$ javac OlympicRingComponent.java
OlympicRingComponent.java:6: warning: The serializable class OlympicRingComponent does not declare a static final serialVersionUID field of type long
public class OlympicRingComponent extends JComponent

I have no idea why this is coming up
Heres my code:
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import javax.swing.JComponent;
import java.awt.Color;
public class OlympicRingComponent extends JComponent
{
	public void paintComponent(Graphics g)
	{
		Graphics2D g2= (Graphics2D) g;
			Ellipse2D.Double ring= new Ellipse2D.Double(100,100,100,100);
			g2.setColor(Color.BLUE);
			g2.draw(ring);
			ring.setFrame(210,100,100,100);
			g2.setColor(Color.BLACK);
			g2.draw(ring);
			ring.setFrame(320,100,100,100);
			g2.setColor(Color.RED);
			g2.draw(ring);
			ring.setFrame(170,170,100,100);
			g2.setColor(Color.YELLOW);
			g2.draw(ring);
			ring.setFrame(280,170,100,100);
			g2.setColor(Color.GREEN);		
			g2.draw(ring);
	}
}



Is This A Good Question/Topic? 0
  • +

Replies To: Warning Error Serializable Class

#2 javadork   User is offline

  • D.I.C Head
  • member icon

Reputation: 32
  • View blog
  • Posts: 135
  • Joined: 21-August 10

Re: Warning Error Serializable Class

Posted 07 October 2010 - 01:56 PM

Are you running this under Eclipse? I recall this warning used to come up in earlier versions of Eclipse, it's safe to ignore.
Was This Post Helpful? 0
  • +
  • -

#3 bcranger   User is offline

  • D.I.C Lover
  • member icon

Reputation: 253
  • View blog
  • Posts: 1,199
  • Joined: 01-February 10

Re: Warning Error Serializable Class

Posted 07 October 2010 - 01:56 PM

Just ignore it. Usually, GUI Builders use them so you can identify them later. No need to have the ID. I Think PBL uses it but I forgot why.
Was This Post Helpful? 0
  • +
  • -

#4 Kurplepush   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 78
  • Joined: 08-March 10

Re: Warning Error Serializable Class

Posted 07 October 2010 - 02:27 PM

How do i get it to compile anyways?
Was This Post Helpful? 0
  • +
  • -

#5 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2975
  • View blog
  • Posts: 11,224
  • Joined: 15-July 08

Re: Warning Error Serializable Class

Posted 07 October 2010 - 02:40 PM

It should compile. It's just a warning. Errors cause it to not compile. Warnings, unless you change the settings, do not PREVENT a compile.
Was This Post Helpful? 0
  • +
  • -

#6 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Warning Error Serializable Class

Posted 07 October 2010 - 02:41 PM

View PostKurplepush, on 07 October 2010 - 03:27 PM, said:

How do i get it to compile anyways?

This is just a warning your program is compiled and should work

If you want to get ride of the warning just insert

static final long serialVersionUID = 1L;

in the instance variables of the class where the warning is issued

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import javax.swing.JComponent;
import java.awt.Color;
public class OlympicRingComponent extends JComponent
{
     static final long serialVersionUID = 1L;

	public void paintComponent(Graphics g)
	{



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1