{"id":1930,"date":"2013-09-07T23:15:05","date_gmt":"2013-09-07T23:15:05","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=1930"},"modified":"2013-09-07T23:15:05","modified_gmt":"2013-09-07T23:15:05","slug":"fixing-scala-error-main-method-is-not-static-in-class-x","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/fixing-scala-error-main-method-is-not-static-in-class-x\/","title":{"rendered":"Fixing Scala Error:  Main method is not static in class X"},"content":{"rendered":"<p>If you set up a Scala HelloWorld example naively, it is easy to get the following perplexing error message:<\/p>\n<pre>:runError: Main method is not static in class com.garysieling.HelloWorld, please define the main method as:\n   public static void main(String[] args)<\/pre>\n<p>This happens if the code looks like the following:<\/p>\n<pre lang=\"scala\">package com.garysieling {\n  class HelloWorld extends App {\n     System.out.println(\"test\")\n  }<\/pre>\n<p>In fact, &#8220;HelloWorld&#8221; must be set as an object, as there are no statics with classes in scala.<\/p>\n<pre lang=\"scala\">package com.garysieling {\n  import scala.App\n\n  object HelloWorld extends App {\n     System.out.println(\"test\")\n  }\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you set up a Scala HelloWorld example naively, it is easy to get the following perplexing error message: :runError: Main method is not static in class com.garysieling.HelloWorld, please define the main method as: public static void main(String[] args) This happens if the code looks like the following: package com.garysieling { class HelloWorld extends App &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/fixing-scala-error-main-method-is-not-static-in-class-x\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Fixing Scala Error:  Main method is not static in class X&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[9],"tags":[258,480],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/1930"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=1930"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/1930\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=1930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=1930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=1930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}