File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes IDEs, Version Control and other tools and the fly likes Eclipse Warning Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Reply Bookmark "Eclipse Warning" Watch "Eclipse Warning" New topic
Author

Eclipse Warning

Sondra Colagrossi
Ranch Hand

Joined: Oct 30, 2002
Posts: 68
I have the following line in my class ( it's from the JAAS tutorial ) -

Eclipse gives me a warning
The static method sleep(long) from the type Thread should be accessed in a static way
What does this mean?
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Sleep is a static method. You should call it like
Thread.sleep(3000);


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 23395

I remember when I first started teaching Java (in 1995!) I made this mistake in my class materials. I've seen other people make the same mistake over the years. It just seems natural to be able to call "sleep()" on some other thread, but it doesn't work that way.


[Jess in Action][AskingGoodQuestions]
Sondra Colagrossi
Ranch Hand

Joined: Oct 30, 2002
Posts: 68
Thanks guys that fixed it.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Sondra Colagrossi:
Thanks guys that fixed it.

BTW, Eclipse could have fixed it for you, too. Just press Ctrl-1 on the error and select the correct fix.
 
 
subject: Eclipse Warning
 
Threads others viewed
static member
override sleep method
Unreachable code in for?
Type safety: Unchecked cast from Object to TreeMap<String,String>
Thread.sleep() does not release lock?
IntelliJ Java IDE