This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes static Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "static" Watch "static" New topic
Author

static

nida lulu
Greenhorn

Joined: Nov 25, 2008
Posts: 10
what does it mean if i have a compiler error saying "non-static method cannot be referenced from a static context"? I was trying to call a method from another class into a method in the current class I am using, i labeled neither one as static, they are both void methods.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37907
    
  22
The static data/methods refer to the class, and instance data may be different for different objects from this class. So static methods don't know which object they are calling, if there are several objects, so the compiler doesn't allow a static method to call anything which is not static.
You are not allowed to use the keywords this and super in a static method, either.

I don't know whether this helps your present problem; please post more details.
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Hi nida,

Can you please put the code (if small enough that you can put) ? It may help to explain more in details.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static
 
Similar Threads
How to call static methods from non static methods
java.util.array not recognised
Static and non Static methods
Please suggest how to inherit static method from class and override one method among that?
Master exam question