• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Accessing a non-static resource from main()

 
Ranch Hand
Posts: 69
IntelliJ IDE Eclipse IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Error: javac "Tile.java" (in directory: /home/killingthemonkey/Java)
Tile.java:26: error: non-static method printTile(Tile) cannot be referenced from a static context
javac "Tile.java" (in directory: /home/killingthemonkey/Java)
printTile(tile);
^

------------------------
Hi. I'm Doug. I'm a lurker.

Well, I've decided to finally work my way through a text on Java. I'm up to the point where I'm creating classes with constructors. I'm getting this error about not able to access non-static method.

Help, please. It would be much appreciated.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Douglas Knapp wrote:Hi. I'm Doug. I'm a lurker.


Hope not.

Regardless: Welcome to JavaRanch.

I'm getting this error about not able to access non-static method.


That's because you haven't created an object, from which you call its instance method.

Winston

[Edit] Beg pard. You have created an object; but you're NOT calling its instance method.
 
Douglas Knapp
Ranch Hand
Posts: 69
IntelliJ IDE Eclipse IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Winston. That fixed it.

As for the lurking thing. Look at my join date and my number of posts...
 
reply
    Bookmark Topic Watch Topic
  • New Topic