File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Compile Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compile Error" Watch "Compile Error" New topic

Compile Error

Hanna S?derbergLarsson

Joined: Feb 01, 2003
Posts: 2
I have the following class:

And it gives this compile error: this static context "this" is not accessible (no instance field or method)
Please tell me why!!!
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
bumper() is a member of the class, so you can't access it from the static main method. Make bumper static.
Or make an instance of the class and invoke bumper() on the instance.
BTW you have another problem with that method, but first get it to compile and run.
[ February 01, 2003: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Hanna S?derbergLarsson

Joined: Feb 01, 2003
Posts: 2
Thank you Barry!
And I know about the other problem, that was what I wanted to achieve I'm doing a lot of silly tests right now!
I agree. Here's the link:
subject: Compile Error
jQuery in Action, 3rd edition