{"id":21128,"date":"2017-04-24T17:25:30","date_gmt":"2017-04-24T17:25:30","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=21128"},"modified":"2017-04-24T17:25:30","modified_gmt":"2017-04-24T17:25:30","slug":"java-compile-error-non-static-method-cannot-be-referenced-from-a-static-context-what-causes-it","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/java-compile-error-non-static-method-cannot-be-referenced-from-a-static-context-what-causes-it\/","title":{"rendered":"Java compile error: non-static method cannot be referenced from a static context &#8211; what causes it?"},"content":{"rendered":"<h1>Tutoring Java programming, this error message might come up.  The tutor talks about a couple of its causes.<\/h1>\n<p>The message<\/p>\n<p style=\"font-family:monospace;font-size:120%\">error:  non-static method <i>MethodX()<\/i> cannot be referenced from a static context<\/p>\n<p>has a couple of causes I know:<\/p>\n<ol>\n<li>The class that contains the <span style=\"font-family:monospace;font-size:120%\">static main<\/span> method contains another method <em>other_method<\/em> that isn&#8217;t static.  <em>other_method<\/em> can&#8217;t be called from the static one unless it, too, is declared <span style=\"font-family:monospace;font-size:120%\">static<\/span>.<\/li>\n<li>An object has been created [Objectx Ox = new Objectx();], but then its method methodx() is called using the class name [Objectx.methodx();]<br \/>\nas opposed to the instance name [Ox.methodx();]\n<\/li>\n<\/ol>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tutoring Java programming, this error message might come up. The tutor talks about a couple of its causes. The message error: non-static method MethodX() cannot be referenced from a static context has a couple of causes I know: The class &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/java-compile-error-non-static-method-cannot-be-referenced-from-a-static-context-what-causes-it\/\"> <span class=\"screen-reader-text\">Java compile error: non-static method cannot be referenced from a static context &#8211; what causes it?<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105,1801],"tags":[2277,2278],"class_list":["post-21128","post","type-post","status-publish","format-standard","hentry","category-computer-science","category-java","tag-java-compile-error-non-static-method-cannot-be-referenced-from-a-static-context","tag-static-method"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/21128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=21128"}],"version-history":[{"count":19,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/21128\/revisions"}],"predecessor-version":[{"id":21147,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/21128\/revisions\/21147"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=21128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=21128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=21128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}