Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.java.* > Newsgroup comp.lang.java.gui

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 02-12-2012, 03:16 PM
A B
Guest
 
Posts: n/a
Default What do these errors mean?

I've finally got around to compiling my program with -Xlint, as the compiler
kept nagging me to. This is what I got. (I've removed some entries for
different bits that caused identical errors.) I haven't a clue what any of
it means or what to do about it; can anyone enlighten me? What's a raw
type, for instance, and what's a serializable class and how do you give it a
definition of serialVersionUID?
----------------------------------------------
Vectorine.java:39: warning: [rawtypes] found raw type: JComboBox
JComboBox droplist = new JComboBox();
^
missing type arguments for generic class JComboBox<E>
where E is a type-variable:
E extends Object declared in class JComboBox

Vectorine.java:39: warning: [rawtypes] found raw type: JComboBox
JComboBox droplist = new JComboBox();
^
missing type arguments for generic class JComboBox<E>
where E is a type-variable:
E extends Object declared in class JComboBox

Vectorine.java:68: warning: [unchecked] unchecked call to addItem(E) as a
member of the raw type JComboBox
droplist.addItem("Compare to what?");
^
where E is a type-variable:
E extends Object declared in class JComboBox

Vectorine.java:71: warning: [unchecked] unchecked call to addItem(E) as a
member of the raw type JComboBox
droplist.addItem("Other planet");
^
where E is a type-variable:
E extends Object declared in class JComboBox

Vectorine.java:143: warning: [static] static method should be qualified by
type name, DatasetReader, instead of by an expression
datareader.getPlanetPositions(planet);
^
Vectorine.java:145: warning: [static] static variable should be qualified by
type name, DatasetReader, instead of by an expression
for (int count=0; count<datareader.planetPositions.length; count++)
^

Vectorine.java:21: warning: [serial] serializable class Vectorine has no
definition of serialVersionUID
public class Vectorine extends JFrame implements ItemListener, MouseListener
^
----------------------------------------------
(DatasetReader is another class in my program, which the main class creates
an instance of so it can use its methods to look up data. Anything else I
should explain, just tell me.)
--
Many thanks,
A. B.
><>

My e-mail address is zen177395 at zendotcodotuk, though I don't check that
account very often.
Post unto others as you would have them post unto you.

Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 02-12-2012, 03:54 PM
Lew
Guest
 
Posts: n/a
Default Re: What do these errors mean?

On Sunday, February 12, 2012 8:16:44 AM UTC-8, A B wrote:
> I've finally got around to compiling my program with -Xlint, as the compiler
> kept nagging me to. This is what I got. (I've removed some entries for
> different bits that caused identical errors.) I haven't a clue what any of
> it means or what to do about it; can anyone enlighten me? What's a raw
> type, for instance, and what's a serializable class and how do you give it a
> definition of serialVersionUID?


You need to read the Java tutorials before you code.
<http://docs.oracle.com/javase/tutorial/index.html>

Every single one of those terms is eminently searchable, did you but take the
effort to do so:
<http://lmgtfy.com/?q=Java+raw+type>

The first result of which points to the Java Language Specification, which has
an entire section on raw types:
<http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#110257>

The tutorial explains your problem:
<http://docs.oracle.com/javase/tutorial/extra/generics/legacy.html>
"When a generic type like Collection is used without a type parameter, it's
called a raw type."

You need to read the Java API docs as you code.
<http://docs.oracle.com/javase/7/docs/api/>

If you look at the docs for 'JComboBox' you will see that it's a generic type:
<http://docs.oracle.com/javase/7/docs/api/javax/swing/JComboBox.html>
You neglected to specify the item type for the combo box.

You show us none of your code, for shame, but clearly you defined your class as
'implements Serializable' ('implements java.io.Serializable'). This is in your
code, so presumably you looked up the API docs for 'Serializable' and read them
thoroughly. Otherwise, why did you use it?

A "serializable class" is one defined that it 'implements Serializable', and in
the Javadocs for that interface they explain about 'serialVersionUID'. Read it.
<http://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html>

Then, do not use 'Serializable'. Do not use it. Stop using it.

Until you have purchased and studied /Effective Java/ (2nd ed.) by Joshua Bloch.
<http://java.sun.com/docs/books/effective/>
which devotes its entire Chapter 11 to serialization and 'Serializable'. You
must not use Java serialization until you properly understand it! /Effective
Java/ has the best explanation of serialization, its dangers (of which there
are many) and how to circumvent them.

Next time, post an SSCCE.
http://sscce.org/

> ----------------------------------------------
> Vectorine.java:39: warning: [rawtypes] found raw type: JComboBox
> JComboBox droplist = new JComboBox();
> ^
> missing type arguments for generic class JComboBox<E>
> where E is a type-variable:
> E extends Object declared in class JComboBox


The message is pretty darned clear. You are missing the type arguments. So add
type arguments! See the Javadocs, linked above.

> ...
> Vectorine.java:21: warning: [serial] serializable class Vectorine has no
> definition of serialVersionUID
> public class Vectorine extends JFrame implements ItemListener, MouseListener
> ^
> ----------------------------------------------


Don't declare the class 'Serializable'.

> (DatasetReader is another class in my program, which the main class creates
> an instance of so it can use its methods to look up data. Anything else I
> should explain, just tell me.)


Stop the hand waving. If code is relevant, show the code, don't just describe
it.
http://sscce.org/

In your case, the problem is not in the code but in insufficient study
beforehand. Read the tutorial before setting finger to keyboard to code again.
*LOOK UP* terms that you don't recognize! Read the Javadocs.

GIYF.

--
Lew
Reply With Quote
  #3 (permalink)  
Old 02-12-2012, 03:55 PM
Knute Johnson
Guest
 
Posts: n/a
Default Re: What do these errors mean?

On 2/12/2012 8:16 AM, A B wrote:
> I've finally got around to compiling my program with -Xlint, as the
> compiler kept nagging me to. This is what I got. (I've removed some
> entries for different bits that caused identical errors.) I haven't a
> clue what any of it means or what to do about it; can anyone enlighten
> me? What's a raw type, for instance, and what's a serializable class and
> how do you give it a definition of serialVersionUID?
> ----------------------------------------------
> Vectorine.java:39: warning: [rawtypes] found raw type: JComboBox
> JComboBox droplist = new JComboBox();
> ^
> missing type arguments for generic class JComboBox<E>
> where E is a type-variable:
> E extends Object declared in class JComboBox
>
> Vectorine.java:39: warning: [rawtypes] found raw type: JComboBox
> JComboBox droplist = new JComboBox();
> ^
> missing type arguments for generic class JComboBox<E>
> where E is a type-variable:
> E extends Object declared in class JComboBox
>
> Vectorine.java:68: warning: [unchecked] unchecked call to addItem(E) as
> a member of the raw type JComboBox
> droplist.addItem("Compare to what?");
> ^
> where E is a type-variable:
> E extends Object declared in class JComboBox
>
> Vectorine.java:71: warning: [unchecked] unchecked call to addItem(E) as
> a member of the raw type JComboBox
> droplist.addItem("Other planet");
> ^
> where E is a type-variable:
> E extends Object declared in class JComboBox
>
> Vectorine.java:143: warning: [static] static method should be qualified
> by type name, DatasetReader, instead of by an expression
> datareader.getPlanetPositions(planet);
> ^
> Vectorine.java:145: warning: [static] static variable should be
> qualified by type name, DatasetReader, instead of by an expression
> for (int count=0; count<datareader.planetPositions.length; count++)
> ^
>
> Vectorine.java:21: warning: [serial] serializable class Vectorine has no
> definition of serialVersionUID
> public class Vectorine extends JFrame implements ItemListener,
> MouseListener
> ^
> ----------------------------------------------
> (DatasetReader is another class in my program, which the main class
> creates an instance of so it can use its methods to look up data.
> Anything else I should explain, just tell me.)
> --
> Many thanks,
> A. B.
>> <>

> My e-mail address is zen177395 at zendotcodotuk, though I don't check
> that account very often.
> Post unto others as you would have them post unto you.


I can tell you are using Java 7, JComboBox has changed to a generic
class. The simple answer is if you are creating a JComboBox of Strings,
declare it thus;

JComboBox<String> box = new JComboBox<String>(String[] items)

--

Knute Johnson
Reply With Quote
  #4 (permalink)  
Old 02-12-2012, 04:07 PM
Lew
Guest
 
Posts: n/a
Default Re: What do these errors mean?

Knute Johnson wrote:
> A B wrote:
> > I've finally got around to compiling my program with -Xlint, as the
> > compiler kept nagging me to. This is what I got. (I've removed some
> > entries for different bits that caused identical errors.) I haven't a
> > clue what any of it means or what to do about it; can anyone enlighten
> > me? What's a raw type, for instance, and what's a serializable class and
> > how do you give it a definition of serialVersionUID?
> > ----------------------------------------------
> > Vectorine.java:39: warning: [rawtypes] found raw type: JComboBox
> > JComboBox droplist = new JComboBox();
> > ^
> > missing type arguments for generic class JComboBox<E>
> > where E is a type-variable:
> > E extends Object declared in class JComboBox

....

> I can tell you are using Java 7, JComboBox has changed to a generic
> class. The simple answer is if you are creating a JComboBox of Strings,
> declare it thus;
>
> JComboBox<String> box = new JComboBox<String>(String[] items)


Or, since it's Java 7,

JComboBox<String> box = new JComboBox<>(items)

(The 'String[]' in an invocation is an error. It is useful to show a possible
type for the argument, but is not compilable as such. So, "A B", be sure to vet
any code before blindly copying and pasting. Usenet code posts are often, as
above, actually pseudocode.)

--
Lew
Reply With Quote
  #5 (permalink)  
Old 02-12-2012, 04:17 PM
Knute Johnson
Guest
 
Posts: n/a
Default Re: What do these errors mean?

On 2/12/2012 9:07 AM, Lew wrote:
> Knute Johnson wrote:
>> A B wrote:
>>> I've finally got around to compiling my program with -Xlint, as the
>>> compiler kept nagging me to. This is what I got. (I've removed some
>>> entries for different bits that caused identical errors.) I haven't a
>>> clue what any of it means or what to do about it; can anyone enlighten
>>> me? What's a raw type, for instance, and what's a serializable class and
>>> how do you give it a definition of serialVersionUID?
>>> ----------------------------------------------
>>> Vectorine.java:39: warning: [rawtypes] found raw type: JComboBox
>>> JComboBox droplist = new JComboBox();
>>> ^
>>> missing type arguments for generic class JComboBox<E>
>>> where E is a type-variable:
>>> E extends Object declared in class JComboBox

> ...
>
>> I can tell you are using Java 7, JComboBox has changed to a generic
>> class. The simple answer is if you are creating a JComboBox of Strings,
>> declare it thus;
>>
>> JComboBox<String> box = new JComboBox<String>(String[] items)

>
> Or, since it's Java 7,
>
> JComboBox<String> box = new JComboBox<>(items)
>
> (The 'String[]' in an invocation is an error. It is useful to show a possible
> type for the argument, but is not compilable as such. So, "A B", be sure to vet
> any code before blindly copying and pasting. Usenet code posts are often, as
> above, actually pseudocode.)
>


True, I pulled it from the Docs, and I did forget that you don't need to
specify the type on the right.

--

Knute Johnson
Reply With Quote
  #6 (permalink)  
Old 02-16-2012, 07:50 PM
A B
Guest
 
Posts: n/a
Default Re: What do these errors mean?

Knute and Lew - thanks very much for explaining how to fix the "raw type"
error. I've finally found out how to fix the other two, but it took me a
LONG time because I'm doing my programming on a computer without an Internet
connection, and for some bizarre reason that seems to mean I can't search
the documentation or use the tutorials. Didn't know where to look in the
contents because I didn't know what the problem was. It's like looking in a
dictionary to find out how to spell something! (My Internet computer is a
laptop with a fixed, daft refresh rate that stops me concentrating.) THAT's
why I asked.

Roedy - I've saved those pages to look at later. May just be me, but they
look much more intelligible than the stupid Javadocs on the same topics.

Sorry I didn't post the code, only I didn't have enough idea where the error
was coming from to do a SSCCE, and the full code would have made the posting
about three feet long!
--
A. B.
><>

My e-mail address is zen177395 at zendotcodotuk, though I don't check that
account very often.
Post unto others as you would have them post unto you.

Reply With Quote
  #7 (permalink)  
Old 02-16-2012, 08:01 PM
Lew
Guest
 
Posts: n/a
Default Re: What do these errors mean?

On Thursday, February 16, 2012 12:50:17 PM UTC-8, A B wrote:
> Knute and Lew - thanks very much for explaining how to fix the "raw type"
> error. I've finally found out how to fix the other two, but it took me a
> LONG time because I'm doing my programming on a computer without an Internet
> connection, and for some bizarre reason that seems to mean I can't search
> the documentation or use the tutorials. Didn't know where to look in the
> contents because I didn't know what the problem was. It's like looking in a
> dictionary to find out how to spell something! (My Internet computer is a
> laptop with a fixed, daft refresh rate that stops me concentrating.) THAT's
> why I asked.


AFAIK, the tutorials and certainly the API docs are downloadable. Next time
you're on the 'Net, download those to a thumb drive and keep that with the
laptop.

Also, get a better laptop.

--
Lew
Reply With Quote
  #8 (permalink)  
Old 02-16-2012, 08:44 PM
A B
Guest
 
Posts: n/a
Default Re: What do these errors mean?

"Lew" <lewbloch@gmail.com> wrote on 16th February:
> On Thursday, February 16, 2012 12:50:17 PM UTC-8, A B wrote:
>> Knute and Lew - thanks very much for explaining how to fix the "raw type"
>> error. I've finally found out how to fix the other two, but it took me a
>> LONG time because I'm doing my programming on a computer without an
>> Internet
>> connection, and for some bizarre reason that seems to mean I can't search
>> the documentation or use the tutorials. Didn't know where to look in the
>> contents because I didn't know what the problem was. It's like looking
>> in a
>> dictionary to find out how to spell something! (My Internet computer is
>> a
>> laptop with a fixed, daft refresh rate that stops me concentrating.)
>> THAT's
>> why I asked.

>
> AFAIK, the tutorials and certainly the API docs are downloadable. Next
> time
> you're on the 'Net, download those to a thumb drive and keep that with the
> laptop.
>
> Also, get a better laptop.


Inclined to agree, but how would you find out which have an adjustable
refresh rate (that goes up to anything useful)? This one ought to; it's
quite an expensive one.

I've got the API docs, it's just that the downloaded copy doesn't seem to
have a search function, so it's trial and error. I can't find any
downloadable tutorials in the byzantine depths of the website; if you can
I'd be very grateful!
--
A. B.
><>

My e-mail address is zen177395 at zendotcodotuk, though I don't check that
account very often.
Post unto others as you would have them post unto you.

Reply With Quote
  #9 (permalink)  
Old 02-16-2012, 09:54 PM
Jeff Higgins
Guest
 
Posts: n/a
Default Re: What do these errors mean?

On 02/16/2012 04:44 PM, A B wrote:

> I've got the API docs, it's just that the downloaded copy doesn't seem
> to have a search function, so it's trial and error. I can't find any
> downloadable tutorials in the byzantine depths of the website; if you
> can I'd be very grateful!

It's kinda hard to see.
Look in the side bar,
under "Tutorial Resources" section,
the link reads "Download the latest Java Tutorials bundle".
<http://docs.oracle.com/javase/tutorial/>

Reply With Quote
  #10 (permalink)  
Old 02-17-2012, 05:21 PM
A B
Guest
 
Posts: n/a
Default Re: What do these errors mean?

"Jeff Higgins" <jeff@invalid.invalid> wrote in message
news:jhk1f2$20k$1@dont-email.me...
> On 02/16/2012 04:44 PM, A B wrote:
>
>> I've got the API docs, it's just that the downloaded copy doesn't seem
>> to have a search function, so it's trial and error. I can't find any
>> downloadable tutorials in the byzantine depths of the website; if you
>> can I'd be very grateful!

> It's kinda hard to see.
> Look in the side bar,
> under "Tutorial Resources" section,
> the link reads "Download the latest Java Tutorials bundle".
> <http://docs.oracle.com/javase/tutorial/>


Hey, thanks! Could have sworn I'd looked there.
--
A. B.
><>

My e-mail address is zen177395 at zendotcodotuk, though I don't check that
account very often.
Post unto others as you would have them post unto you.

Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 04:46 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.