Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / May 2004

Tip: Looking for answers? Try searching our database.

warning in java IDE

Thread view: 
Generic Usenet Account - 07 May 2004 17:30 GMT
When I opened a java class, I got the following warning in the following line:

MyRec rec = new MyRec();
rec.getField(); <---- should use Class name when accessing static method
 (or something to that effect).

It also puts a yellow marker next to that line.

After I did some other stuff (like compiling, creating a new class etc.),
that warning went away! Now I do not see anything. Any ideas? How can I get
all the warnings back?

Thanks,
Siva
Wald - 07 May 2004 20:26 GMT
> When I opened a java class, I got the following warning in the
> following line:
[quoted text clipped - 3 lines]
>  method
>   (or something to that effect).

That means getField() is declared as a static method in class MyRec. It's
more logical to call it by using the class name itself, rather than the
corresponding object's name.

So: use MyRec.getField() instead.

> It also puts a yellow marker next to that line.
>
> After I did some other stuff (like compiling, creating a new class
> etc.), that warning went away! Now I do not see anything. Any ideas?
> How can I get all the warnings back?

A big problem here is that you don't even mention which IDE you use.

Two possibilities:

- you removed the static identifier from the method getField()

- you tweaked some option in your IDE to ignore non-static access to static
members.

That's about everything I can say to help you, without more information.

Hope it helps,
Wald
Tony Morris - 08 May 2004 09:03 GMT
> After I did some other stuff (like compiling, creating a new class etc.),
> that warning went away! Now I do not see anything. Any ideas? How can I get
> all the warnings back?

http://www.xdweb.net/~dibblego/java/faq/answers.html#q34

Signature

Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)

Andy Fish - 13 May 2004 09:20 GMT
> When I opened a java class, I got the following warning in the following line:
>
[quoted text clipped - 7 lines]
> that warning went away! Now I do not see anything. Any ideas? How can I get
> all the warnings back?

sometimes I find with NetBeans the warning stays for a while after you have
fixed the problem. it just be that you had already fixed it but the view had
not refreshed itself

> Thanks,
> Siva


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.