File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Can't make static reference to method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Can Watch "Can New topic

Can't make static reference to method

simplex du

Joined: Mar 25, 2002
Posts: 24
what cause this compilation error?--thanks
Kathy Rogers
Ranch Hand

Joined: Aug 04, 2000
Posts: 104
Somewhere within your code, you're making a call to an instance method of a class - but you're doing that from within a static method so you're not calling that method on a specific instance. For example, you might be doing something like this:-

whereas what your main method needs to look like it this:-

or alternatively, it might be appropriate to make the printMessage method static.
Hope this helps,
[ June 26, 2002: Message edited by: Kathy Rogers ]
I agree. Here's the link:
subject: Can't make static reference to method
It's not a secret anymore!