{"id":683,"date":"2012-07-26T11:50:24","date_gmt":"2012-07-26T10:50:24","guid":{"rendered":"http:\/\/www.xenonique.co.uk\/blog\/?p=683"},"modified":"2012-07-26T11:50:24","modified_gmt":"2012-07-26T10:50:24","slug":"scalafx-working-configuration-for-macos-x-lion-java-7-update-5","status":"publish","type":"post","link":"https:\/\/www.xenonique.co.uk\/blog\/2012\/07\/26\/scalafx-working-configuration-for-macos-x-lion-java-7-update-5\/","title":{"rendered":"ScalaFX &#8211; Working Configuration for MacOS X Lion, Java 7 Update 5"},"content":{"rendered":"<p>Here is a complete verbatim <code>build.sbt<\/code> for <a href=\"https:\/\/code.google.com\/p\/scalafx\/\" title=\"ScalaFX Project\"><strong>ScalaFX<\/strong><\/a> that works on <a href=\"https:\/\/www.apple.com\/uk\/osx\/\" title=\"Apple Mac OS X Lion\"><strong>MacOS X Lion<\/strong><\/a> and <a href=\"https:\/\/java.oracle.com\" title=\"Oracle Java SE 7 \">Java SE 7 Update 5<\/a>:<\/p>\n<pre class=\"brush: scala; title: ; notranslate\" title=\"\">\r\n\/\/ Important - Set the JAVAFX_HOME environment variable to the root of your JavaFX installation for this script to work\r\n\r\n\/\/ You can also set your scala or java home if necessary like this:\r\n\/\/ javaHome := Some(file(&quot;\/Library\/Java\/JavaVirtualMachines\/1.6.0_24-b07-330.jdk\/Contents\/Home&quot;))\r\n\/\/ scalaHome := Some(file(&quot;\/Users\/Sven\/scala-2.9.1\/&quot;))\r\n\/\/ javaHome := Some(file(&quot;\/Library\/Java\/JavaVirtualMachines\/1.7.0.jdk\/Contents\/Home&quot;))\r\n\r\njavaHome := Some(file(System.getenv(&quot;JAVA_HOME&quot;)))\r\n\r\nname := &quot;ScalaFX&quot;\r\n\r\nversion := &quot;1.0-SNAPSHOT&quot;\r\n\r\norganization := &quot;org.scalafx&quot;\r\n\r\nscalaVersion := &quot;2.9.2&quot;\r\n\r\nresolvers += &quot;Local Maven Repository&quot; at &quot;file:\/\/&quot;+Path.userHome.absolutePath+&quot;\/.m2\/repository&quot;\r\n\r\nunmanagedSourceDirectories in Compile &lt;++= baseDirectory { base =&gt;\r\n  Seq(\r\n    base \/ &quot;src&quot;,\r\n    base \/ &quot;demo&quot;\r\n  )\r\n}\r\n\r\n\/\/ set the Scala test source directory to be &lt;base&gt;\/test\r\nscalaSource in Test &lt;&lt;= baseDirectory(_ \/ &quot;test&quot;)\r\n\r\n\/\/ testListeners &lt;&lt;= target.map(t =&gt; Seq(new eu.henkelmann.sbt.JUnitXmlTestsListener(t.getAbsolutePath)))\r\n\r\n\/\/ append several options to the list of options passed to the Java compiler\r\njavacOptions ++= Seq(&quot;-source&quot;, &quot;1.5&quot;, &quot;-target&quot;, &quot;1.5&quot;)\r\n\r\n\/\/ append -deprecation to the options passed to the Scala compiler\r\nscalacOptions += &quot;-deprecation&quot;\r\n\r\n\/\/ define the statements initially evaluated when entering 'console', 'console-quick', or 'console-project'\r\ninitialCommands := &quot;&quot;&quot;\r\n  import System.{currentTimeMillis =&gt; now}\r\n  def time[T](f: =&gt; T): T = {\r\n    val start = now\r\n    try { f } finally { println(&quot;Elapsed: &quot; + (now - start)\/1000.0 + &quot; s&quot;) }\r\n  }\r\n&quot;&quot;&quot;\r\n\r\n\/\/ libraryDependencies += &quot;com.oracle&quot; % &quot;javafx-runtime&quot; % &quot;2.1&quot;\r\n\r\n\/\/ set the main class for the main 'run' task\r\n\/\/ change Compile to Test to set it for 'test:run'\r\nmainClass in (Compile, run) := Some(&quot;scalafx.ColorfulCircles&quot;)\r\n\r\n\/\/ add &lt;base&gt;\/input to the files that '~' triggers on\r\nwatchSources &lt;+= baseDirectory map { _ \/ &quot;input&quot; }\r\n\r\n\/\/ disable updating dynamic revisions (including -SNAPSHOT versions)\r\noffline := true\r\n\r\n\/\/ set the prompt (for this build) to include the project id.\r\nshellPrompt in ThisBuild := { state =&gt; Project.extract(state).currentRef.project + &quot;&gt; &quot; }\r\n\r\n\/\/ set the prompt (for the current project) to include the username\r\nshellPrompt := { state =&gt; System.getProperty(&quot;user.name&quot;) + &quot; (SBT) &gt; &quot; }\r\n\r\n\/\/ disable printing timing information, but still print [success]\r\nshowTiming := false\r\n\r\n\/\/ disable printing a message indicating the success or failure of running a task\r\nshowSuccess := false\r\n\r\n\/\/ change the format used for printing task completion time\r\ntimingFormat := {\r\n    import java.text.DateFormat\r\n    DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)\r\n}\r\n\r\n\/\/ disable using the Scala version in output paths and artifacts\r\ncrossPaths := false\r\n\r\n\/\/ fork a new JVM for 'run' and 'test:run'\r\nfork := true\r\n\r\n\/\/ fork a new JVM for 'test:run', but not 'run'\r\nfork in Test := true\r\n\r\n\/\/ add a JVM option to use when forking a JVM for 'run'\r\njavaOptions ++= Seq (\r\n  &quot;-Xmx512M&quot; ,\r\n  &quot;-Djavafx.verbose&quot;\r\n)\r\n\r\n\/\/ only use a single thread for building\r\nparallelExecution := false\r\n\r\n\/\/ Execute tests in the current project serially\r\n\/\/   Tests from other projects may still run concurrently.\r\nparallelExecution in Test := false\r\n\r\n\/\/ add JavaFX 2.0 to the unmanaged classpath\r\nunmanagedJars in Compile += Attributed.blank(file(System.getenv(&quot;JAVA_HOME&quot;) + &quot;\/jre\/lib\/jfxrt.jar&quot;))\r\n\r\n\/\/ publish test jar, sources, and docs\r\npublishArtifact in Test := false\r\n\r\n\/\/ disable publishing of main docs\r\npublishArtifact in (Compile, packageDoc) := false\r\n\r\n\/\/ change the classifier for the docs artifact\r\nartifactClassifier in packageDoc := Some(&quot;doc&quot;)\r\n\r\n\/\/ Copy all managed dependencies to &lt;build-root&gt;\/lib_managed\/\r\n\/\/   This is essentially a project-local cache and is different\r\n\/\/   from the lib_managed\/ in sbt 0.7.x.  There is only one\r\n\/\/   lib_managed\/ in the build root (not per-project).\r\nretrieveManaged := true\r\n\r\n\/* Specify a file containing credentials for publishing. The format is:\r\nrealm=Sonatype Nexus Repository Manager\r\nhost=nexus.scala-tools.org\r\nuser=admin\r\npassword=admin123\r\n*\/\r\ncredentials += Credentials(Path.userHome \/ &quot;.ivy2&quot; \/ &quot;.credentials&quot;)\r\n\r\n\/\/ Directly specify credentials for publishing.\r\ncredentials += Credentials(&quot;Sonatype Nexus Repository Manager&quot;, &quot;nexus.scala-tools.org&quot;, &quot;admin&quot;, &quot;admin123&quot;)\r\n\r\npublishMavenStyle := true\r\n\r\npublishTo := Some(Resolver.file( &quot;file&quot;,  new File( Path.userHome + &quot;\/.m2\/repository&quot; )) )\r\n# End\r\n<\/pre>\n<p>Java 7 up to Update 5 already includes JavaFX 2.1. Therefore there is no need to explicitly install in the jfxrt.jar inside a Maven directory. However, I am unsure how to link ScalaFX with JavaFX 2.2 beta and 3.0 code from the OpenJfx repositories; and how the platform toolkit with those codebases for Mac OS X explicitly loads native libraries at initialisation.<\/p>\n<p>On a new Mac OS machine, especially Lion, you will definitely want to re-enable Java to run inside web browsers. You might also want to prefer to use as a default the Java SE 7 from Oracle instead of the Apple JDK 6 release. Fire up the Java Preferences App. Open a terminal and execute the following command at the Bash shell prompt.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; ls -lF \/Applications\/Utilities\/Java\\ Preferences.app\/Contents\/MacOS\/Java\\ Preferences \r\n-rwxr-xr-x  1 root  wheel  39072 18 Jul 02:55 \/Applications\/Utilities\/Java Preferences.app\/Contents\/MacOS\/Java Preferences*\r\n&gt; \/Applications\/Utilities\/Java\\ Preferences.app\/Contents\/MacOS\/Java\\ Preferences  \r\n<\/pre>\n<p>Re-enable JRE to run inside all of your installed web browsers: Firefox, Chrome and Safari. Select Java 7 Runtime Environment with the mouse, drag it to the top of the list. Check that Java 7 is now the default.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&gt; \/usr\/libexec\/java_home\r\n\/Library\/Java\/JavaVirtualMachines\/1.7.0.jdk\/Contents\/Home\r\n<\/pre>\n<p>You can add this call to your <code>~\/.bash_profile<\/code> script, so your Java environment is automated every time you fire up a terminal command.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nexport JAVA_HOME=`\/usr\/libexec\/java_home`\r\n\r\nexport PATH=${JAVA_HOME}\/bin:${JAVA_HOME}\/jre\/bin:[whatever your path was before&gt;]\r\n<\/pre>\n<p>Finally, the <code>java_home<\/code> program can dump a list of your installed JREs.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmacosx [248] &gt; \/usr\/libexec\/java_home -V\r\nMatching Java Virtual Machines (3):\r\n    1.7.0_05, x86_64:\t&quot;Java SE 7&quot;\t\/Library\/Java\/JavaVirtualMachines\/1.7.0.jdk\/Contents\/Home\r\n    1.6.0_33-b03-424, x86_64:\t&quot;Java SE 6&quot;\t\/System\/Library\/Java\/JavaVirtualMachines\/1.6.0.jdk\/Contents\/Home\r\n    1.6.0_33-b03-424, i386:\t&quot;Java SE 6&quot;\t\/System\/Library\/Java\/JavaVirtualMachines\/1.6.0.jdk\/Contents\/Home\r\n\r\n\/Library\/Java\/JavaVirtualMachines\/1.7.0.jdk\/Contents\/Home\r\nmacosx [249] &gt; \/usr\/libexec\/java_home -X\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\r\n&lt;!DOCTYPE plist PUBLIC &quot;-\/\/Apple\/\/DTD PLIST 1.0\/\/EN&quot; &quot;https:\/\/www.apple.com\/DTDs\/PropertyList-1.0.dtd&quot;&gt;\r\n&lt;plist version=&quot;1.0&quot;&gt;\r\n&lt;array&gt;\r\n\t&lt;dict&gt;\r\n\t\t&lt;key&gt;JVMArch&lt;\/key&gt;\r\n\t\t&lt;string&gt;x86_64&lt;\/string&gt;\r\n\t\t&lt;key&gt;JVMBlacklisted&lt;\/key&gt;\r\n\t\t&lt;false\/&gt;\r\n\t\t&lt;key&gt;JVMBundleID&lt;\/key&gt;\r\n\t\t&lt;string&gt;com.oracle.java.7u05.jdk&lt;\/string&gt;\r\n\t\t&lt;key&gt;JVMEnabled&lt;\/key&gt;\r\n\t\t&lt;true\/&gt;\r\n\t\t&lt;key&gt;JVMHomePath&lt;\/key&gt;\r\n\t\t&lt;string&gt;\/Library\/Java\/JavaVirtualMachines\/1.7.0.jdk\/Contents\/Home&lt;\/string&gt;\r\n\t\t&lt;key&gt;JVMIsBuiltIn&lt;\/key&gt;\r\n\t\t&lt;false\/&gt;\r\n\t\t&lt;key&gt;JVMName&lt;\/key&gt;\r\n\t\t&lt;string&gt;Java SE 7&lt;\/string&gt;\r\n\t\t&lt;key&gt;JVMPlatformVersion&lt;\/key&gt;\r\n\t\t&lt;string&gt;1.7&lt;\/string&gt;\r\n\t\t&lt;key&gt;JVMVendor&lt;\/key&gt;\r\n\t\t&lt;string&gt;Oracle Corporation&lt;\/string&gt;\r\n\t\t&lt;key&gt;JVMVersion&lt;\/key&gt;\r\n\t\t&lt;string&gt;1.7.0_05&lt;\/string&gt;\r\n\t&lt;\/dict&gt;\r\n\t&lt;dict&gt;\r\n\t\t&lt;key&gt;JVMArch&lt;\/key&gt;\r\n\t\t&lt;string&gt;x86_64&lt;\/string&gt;\r\n\t\t&lt;key&gt;JVMBlacklist\r\n        ...\r\n&lt;\/plist&gt; \r\n<\/pre>\n<p>+PP+<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is a complete verbatim build.sbt for ScalaFX that works on MacOS X Lion and Java SE 7 Update 5: Java 7 up to Update 5 already includes JavaFX 2.1. Therefore there is no need to explicitly install in the jfxrt.jar inside a Maven directory. However, I am unsure how to link ScalaFX with JavaFX [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[75,129,5,144,6,105,138],"tags":[],"_links":{"self":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts\/683"}],"collection":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=683"}],"version-history":[{"count":9,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts\/683\/revisions"}],"predecessor-version":[{"id":692,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts\/683\/revisions\/692"}],"wp:attachment":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}