{"id":26737,"date":"2016-12-05T03:01:36","date_gmt":"2016-12-04T17:01:36","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=26737"},"modified":"2022-05-04T13:27:14","modified_gmt":"2022-05-04T03:27:14","slug":"scala-hello-world-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/scala-hello-world-primer-tutorial\/","title":{"rendered":"Scala Hello World Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/scala_netbeans.jpg\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Scala Hello World Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Mac\/scala_netbeans.jpg\" title=\"Scala Hello World Primer Tutorial\"  style=\"float:left;\"  \/><\/a><p class=\"wp-caption-text\">Scala Hello World Primer Tutorial<\/p><\/div>\n<p>The <a target=_blank href='https:\/\/www.scala-lang.org\/'>Scala<\/a> programming language is a burgeoning force in Information Technology &#8230;<\/p>\n<blockquote cite=\"https:\/\/www.scala-lang.org\/\"><p>\nObject-Oriented Meets Functional<br \/>\n&nbsp;<br \/>\nHave the best of both worlds. Construct elegant class hierarchies for maximum code reuse and extensibility, implement their behavior using higher-order functions. Or anything in-between.\n<\/p><\/blockquote>\n<p> &#8230; and we want to find out more about it, so today we start down that long and winding road.  So where else would a beginner begin, barring running a complete sample project, as to construct our own Hello World Scala application, with a lot of help from others (thanks), ourselves.<\/p>\n<p>Steps in getting together a Scala command line Hello World application, and to ready the NetBeans 8.0.2 IDE for Scala Sbt Project creations into the future, given our NetBeans 8.0.2 \/ No Scala \/ Java SE 1.7 starting point, involved &#8230;<\/p>\n<ol>\n<li>Java SE 1.8 is needed for Scala (via sbt) work and we installed via <a target=_blank title='http:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/jdk8-downloads-2133151.html' href='http:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/jdk8-downloads-2133151.html'>HTTP:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/jdk8-downloads-2133151.html<\/a>\n<\/li>\n<li>Install Scala 2.12.0 via <a target=_blank title='https:\/\/www.scala-lang.org\/download\/' href='https:\/\/www.scala-lang.org\/download\/'>https:\/\/www.scala-lang.org\/download\/<\/a>\n<\/li>\n<li>Make it work on command line in our \/usr\/local\/bin\/scala-2.12.0 base directory, on our command line (via Terminal) $PATH\n<\/li>\n<li>Advice of <a target=_blank title='https:\/\/www.macports.org\/install.php' href='https:\/\/www.macports.org\/install.php'>https:\/\/www.macports.org\/install.php<\/a> had us reinstalling Xcode command line tools from Apple Developer Store because of recent upgrade of Mac OS X to macOS Sierra Version 10.12.1 &#8230; followed by<br \/>\n<code><br \/>\nsudo xcodebuild -license<br \/>\n<\/code>\n<\/li>\n<li>Reinstall base Macports via Download button of <a target=_blank title='https:\/\/www.macports.org\/install.php' href='https:\/\/www.macports.org\/install.php'>https:\/\/www.macports.org\/install.php<\/a> because of recent upgrade of Mac OS X to macOS Sierra Version 10.12.1\n<\/li>\n<li>Install sbt version 0.13.11 via Macports &#8230;<br \/>\n<code><br \/>\nsudo port install sbt<br \/>\n<\/code><br \/>\n &#8230; alternatively install via <a target=_blank title='sbt landing page' href='http:\/\/www.scala-sbt.org\/'>sbt landing page<\/a> &#8230;<\/p>\n<blockquote cite=\"http:\/\/www.scala-sbt.org\/\"><p>\nThe interactive build tool<br \/>\n&nbsp;<br \/>\nUse Scala to define your tasks. Then run them in parallel from the shell.\n<\/p><\/blockquote>\n<\/li>\n<li>Start up NetBeans 8.0.2\n<\/li>\n<li>Tools -&gt; Java Platforms show Java SE 1.8\n<\/li>\n<li>Tools -&gt; Scala Platforms shows no relationships\n<\/li>\n<li>Tools -&gt; Plugins -&gt; Available Plugins &#8230; Sort and check all the Scala ones and -&gt; Install &#8230; as you can see a bit of with today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Mac\/scala_netbeans.jpg\" title='Click picture'>tutorial picture<\/a>\n<\/li>\n<li>Tools -&gt; Scala -&gt; Sources tab -&gt; Add JAR\/Folder&#8230; and add all the *.jar in \/usr\/local\/bin\/scala-2.12.0\/lib directory\n<\/li>\n<li>At Terminal command line &#8230;<br \/>\n<code><br \/>\n$ cd $HOME<br \/>\n$ pwd<br \/>\n\/Library\/pgAgent<br \/>\n$ mkdir scala_sbt_hello_world<br \/>\n$ cd scala_sbt_hello_world<br \/>\n$ echo 'object Hi { def main(args: Array[String]) = println(\"Hello World ... Scala fans!\") }' &gt; helloworld.scala<br \/>\n$ sbt<br \/>\nJava HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=384m; support was removed in 8.0<br \/>\n[info] Set current project to scala_sbt_hello_world (in build file:\/Library\/pgAgent\/scala_sbt_hello_world\/)<br \/>\n> run<br \/>\n[info] Updating {file:\/Library\/pgAgent\/scala_sbt_hello_world\/}scala_sbt_hello_world...<br \/>\n[info] Resolving org.fusesource.jansi#jansi;1.4 ...<br \/>\n[info] Done updating.<br \/>\n[info] Compiling 1 Scala source to \/Library\/pgAgent\/scala_sbt_hello_world\/target\/scala-2.10\/classes...<br \/>\n[info] 'compiler-interface' not yet compiled for Scala 2.10.6. Compiling...<br \/>\n[info]   Compilation completed in 24.13 s<br \/>\n[info] Running Hi<br \/>\nHello World ... Scala fans!<br \/>\n[success] Total time: 44 s, completed 04\/12\/2016 3:37:10 PM<br \/>\n> exit<br \/>\n$<br \/>\n<\/code>\n<\/li>\n<\/ol>\n<p>Great help (thanks heaps) came from &#8230;<\/p>\n<ul>\n<li><a target=_blank title='https:\/\/blogs.oracle.com\/geertjan\/entry\/10_steps_to_happiness_with' href='https:\/\/blogs.oracle.com\/geertjan\/entry\/10_steps_to_happiness_with'>https:\/\/blogs.oracle.com\/geertjan\/entry\/10_steps_to_happiness_with<\/a> &#8230; for all but the NetBeans 8.0.2 (Java SE 1.8 Scala 2.12.0) -&gt; New Project (Scala) list only having Scala SBT Project option &#8230; so also consulted &#8230;<\/li>\n<li><a target=_blank title='http:\/\/www.scala-sbt.org\/0.12.4\/docs\/Getting-Started\/Hello.html' href='http:\/\/www.scala-sbt.org\/0.12.4\/docs\/Getting-Started\/Hello.html'>HTTP:\/\/www.scala-sbt.org\/0.12.4\/docs\/Getting-Started\/Hello.html<\/a><\/li>\n<\/ul>\n<p>You may face the same dilemmas as us, so below is a list of pertinent &#8220;other&#8221; parts of the Scala research and development &#8230;<\/p>\n<ul>\n<li><a target=_blank title='http:\/\/stackoverflow.com\/questions\/8461013\/how-to-check-sbt-version' href='http:\/\/stackoverflow.com\/questions\/8461013\/how-to-check-sbt-version'>HTTP:\/\/stackoverflow.com\/questions\/8461013\/how-to-check-sbt-version<\/a>\n<\/li>\n<li><a target=_blank title='https:\/\/github.com\/dcaoyuan\/nbsbt' href='https:\/\/github.com\/dcaoyuan\/nbsbt'>https:\/\/github.com\/dcaoyuan\/nbsbt<\/a>\n<\/li>\n<li><a target=_blank title='http:\/\/stackoverflow.com\/questions\/31683539\/scala-application-missing-in-netbeans-8-0-2-projects-under-windows' href='http:\/\/stackoverflow.com\/questions\/31683539\/scala-application-missing-in-netbeans-8-0-2-projects-under-windows'>HTTP:\/\/stackoverflow.com\/questions\/31683539\/scala-application-missing-in-netbeans-8-0-2-projects-under-windows<\/a>\n<\/li>\n<li><a target=_blank title='http:\/\/forums.netbeans.org\/topic62461.html' href='http:\/\/forums.netbeans.org\/topic62461.html'>HTTP:\/\/forums.netbeans.org\/topic62461.html<\/a>\n<\/li>\n<li><a target=_blank title='https:\/\/sourceforge.net\/projects\/erlybird\/files\/nb-scala\/' href='https:\/\/sourceforge.net\/projects\/erlybird\/files\/nb-scala\/'>https:\/\/sourceforge.net\/projects\/erlybird\/files\/nb-scala\/<\/a>\n<\/li>\n<li><a target=_blank title='http:\/\/www.scala-lang.org\/news\/2.12.0' href='http:\/\/www.scala-lang.org\/news\/2.12.0'>HTTP:\/\/www.scala-lang.org\/news\/2.12.0<\/a>\n<\/li>\n<li><a target=_blank title='http:\/\/www.java2s.com\/Code\/Jar\/s\/Downloadscalacompilersrcjar.htm' href='http:\/\/www.java2s.com\/Code\/Jar\/s\/Downloadscalacompilersrcjar.htm'>HTTP:\/\/www.java2s.com\/Code\/Jar\/s\/Downloadscalacompilersrcjar.htm<\/a>\n<\/li>\n<p><!--li><a target=_blank title='http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/8u111-b14\/jdk-8u111-macosx-x64.dmg?AuthParam=1480822803_70f90a17a9663676d6ad884b2039c57c' href='http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/8u111-b14\/jdk-8u111-macosx-x64.dmg?AuthParam=1480822803_70f90a17a9663676d6ad884b2039c57c'>HTTP:\/\/download.oracle.com\/otn-pub\/java\/jdk\/8u111-b14\/jdk-8u111-macosx-x64.dmg?AuthParam=1480822803_70f90a17a9663676d6ad884b2039c57c<\/a><\/li-->\n<li><a target=_blank title='https:\/\/docs.oracle.com\/javase\/8\/docs\/technotes\/guides\/install\/mac_jdk.html' href='https:\/\/docs.oracle.com\/javase\/8\/docs\/technotes\/guides\/install\/mac_jdk.html'>https:\/\/docs.oracle.com\/javase\/8\/docs\/technotes\/guides\/install\/mac_jdk.html<\/a>\n<\/li>\n<li><a target=_blank title='http:\/\/stackoverflow.com\/questions\/18144660\/what-is-path-of-jdk-on-mac' href='http:\/\/stackoverflow.com\/questions\/18144660\/what-is-path-of-jdk-on-mac'>HTTP:\/\/stackoverflow.com\/questions\/18144660\/what-is-path-of-jdk-on-mac<\/a>\n<\/li>\n<li><a target=_blank title='http:\/\/crunchify.com\/where-is-java-installed-on-my-mac-osx-system\/' href='http:\/\/crunchify.com\/where-is-java-installed-on-my-mac-osx-system\/'>HTTP:\/\/crunchify.com\/where-is-java-installed-on-my-mac-osx-system\/<\/a>\n<\/li>\n<li><a target=_blank title='https:\/\/netbeans.org\/kb\/docs\/java\/javase-jdk8.html#platform' href='https:\/\/netbeans.org\/kb\/docs\/java\/javase-jdk8.html#platform'>https:\/\/netbeans.org\/kb\/docs\/java\/javase-jdk8.html#platform<\/a>\n<\/ul>\n<p>We hope, if you are one of those interested in Scala, this tutorial helps a little with your launching into finding out more.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d26737' onclick='var dv=document.getElementById(\"d26737\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/scala\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d26737' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The Scala programming language is a burgeoning force in Information Technology &#8230; Object-Oriented Meets Functional &nbsp; Have the best of both worlds. Construct elegant class hierarchies for maximum code reuse and extensibility, implement their behavior using higher-order functions. Or anything &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/scala-hello-world-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,24,29,37],"tags":[93,234,319,558,585,611,644,647,725,2069,735,833,885,956,2070,2071,1252],"class_list":["post-26737","post","type-post","status-publish","format-standard","hentry","category-elearning","category-netbeans","category-operating-system","category-tutorials","tag-apple-store","tag-command-line","tag-desktop","tag-hello-world","tag-ide","tag-install","tag-java","tag-java-se","tag-mac-os-x","tag-macos-sierra","tag-macports","tag-netbeans","tag-operating-system-2","tag-plugin","tag-sbt","tag-scala","tag-terminal"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/26737"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=26737"}],"version-history":[{"count":9,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/26737\/revisions"}],"predecessor-version":[{"id":55630,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/26737\/revisions\/55630"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=26737"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=26737"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=26737"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}