This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Accessing a non-static resource from main() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Accessing a non-static resource from main()" Watch "Accessing a non-static resource from main()" New topic
Author

Accessing a non-static resource from main()

Douglas Knapp
Greenhorn

Joined: Feb 14, 2012
Posts: 24


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.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7081
    
  16

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.

Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
Douglas Knapp
Greenhorn

Joined: Feb 14, 2012
Posts: 24
Thanks, Winston. That fixed it.

As for the lurking thing. Look at my join date and my number of posts...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing a non-static resource from main()
 
Similar Threads
invoking methods while inside methods
Character manipulation questions?
Beginning to use classes
At the main method create a single dimension array
launching application with java command line