Results 1 to 4 of 4
- 04-09-2011, 01:05 AM #1
Member
- Join Date
- Apr 2010
- Location
- Virginia, USA
- Posts
- 12
- Rep Power
- 0
Javac Error Message Interpretation
Hello All.
I am reading the book Java in easy steps and I am getting a javac error when compiling the code in the book. Here's the error:
The serializable class HelloWorldApplet does not declare a static final serialVersionUID field of type long
public class HelloWorldApplet extends JApplet
The code:
This is placed in a BARE BONES html document. My question is what does the error mean?Java Code:import javax.swing.*; import java.awt.*; public class HelloWorldApplet extends JApplet { String message; public void init() { message = "Hello World2"; } public void paint(Graphics artist) { artist.drawString(message, 20,30); } }
- 04-09-2011, 02:22 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,546
- Rep Power
- 11
First observe that this is not an error, nor is it reported by the javac compiler.
Java Code:C:\Documents and Settings\pbrockway2\Desktop>type HelloWorldApplet.java import javax.swing.*; import java.awt.*; public class HelloWorldApplet extends JApplet { String message; public void init() { message = "Hello World2"; } public void paint(Graphics artist) { artist.drawString(message, 20,30); } } C:\Documents and Settings\pbrockway2\Desktop>javac -cp . HelloWorldApplet .java C:\Documents and Settings\pbrockway2\Desktop>
You can get the compiler to report this message by using one of the -X options.
Java Code:C:\Documents and Settings\pbrockway2\Desktop>javac -Xlint -cp . HelloWorl dApplet.java HelloWorldApplet.java:4: warning: [serial] serializable class HelloWorldApplet h as no definition of serialVersionUID public class HelloWorldApplet extends JApplet ^ 1 warning C:\Documents and Settings\pbrockway2\Desktop>
So, it's a warning not an error. And you can basically ignore it. (Or compile from the command line in which case ... you never see it).
--------------
There is a description of what this (not really "New to Java") problem is at stackoverflow. Where the recommend telling your IDE to ignore the lack of id, or to autogenerate one.
- 04-09-2011, 01:46 PM #3
Member
- Join Date
- Apr 2010
- Location
- Virginia, USA
- Posts
- 12
- Rep Power
- 0
Thanks for your reply. I do see now where it's just a warning and not an error. My code did run as expected. I did look at the link and attempt to decipher the thread - I've still got the training wheels on so I am not grasping everything but do want to immerse myself.
- 04-09-2011, 09:37 PM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,546
- Rep Power
- 11
Similar Threads
-
Javac error
By Sotsiak in forum New To JavaReplies: 5Last Post: 06-04-2010, 08:33 AM -
Javac error
By Zorobay in forum New To JavaReplies: 14Last Post: 03-03-2010, 12:00 AM -
error while compile code using javac
By suri in forum New To JavaReplies: 3Last Post: 01-20-2010, 09:10 AM -
===javac error===
By solt in forum New To JavaReplies: 21Last Post: 12-06-2009, 09:18 AM -
Interpretation of regex?
By Ms.Ranjan in forum New To JavaReplies: 2Last Post: 04-23-2009, 06:37 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks