{"id":963,"date":"2013-11-13T17:48:22","date_gmt":"2013-11-13T16:48:22","guid":{"rendered":"https:\/\/mihosoft.eu\/?p=963"},"modified":"2014-09-12T22:12:27","modified_gmt":"2014-09-12T20:12:27","slug":"deploy-openjfx-8-apps-to-the-mac-app-store-part-1","status":"publish","type":"post","link":"https:\/\/mihosoft.eu\/?p=963","title":{"rendered":"Deploy OpenJFX 8 Apps To The Mac App Store [Part 1]"},"content":{"rendered":"<p>**[Update: 19.11.2013]: ** <a href=\"https:\/\/mihosoft.eu\/?p=1000\">gradle script available<\/a> that simplifies the process dramatically!<\/p>\n\n<p>Java 8 is a major update from a language perspective and also from a platform perspective. It brings new APIs and significant syntax improvements such as lambda expressions. JavaFX brings support for 3D nodes, highly improved Swing integration, new controls and much more.<\/p>\n\n<p>Many developers do not move to Java 8\/JavaFX 8 as it has not been officially released yet and it is not allowed to use the EA builds for releasing applications (we can&#8217;t ship the EA runtime). The expected release date is March 2014.<\/p>\n\n<h2>Use JavaFX 8 Today!<\/h2>\n\n<p>But the great thing is that Java 8 and JavaFX 8 are fully open sourced now. This allows to create release builds of OpenJDK and OpenJFX (the open source versions of Java 8 and JavaFX 8). To test how well this works I recently submitted <a href=\"https:\/\/mihosoft.eu\/?p=952\">VPlot<\/a>, an OpenJFX 8 app to the <a href=\"https:\/\/itunes.apple.com\/us\/app\/vplot\/id727109209?l=de&amp;ls=1&amp;mt=12\">Mac App Store<\/a> that makes use of the 3D integration that is now part of JavaFX 8.<\/p>\n\n<h2>Contents<\/h2>\n\n<p>In this part of the tutorial you will learn how to build your own OpenJDK 8 image including OpenJFX 8.<\/p>\n\n<h2>Compile OpenJDK 8 &amp; OpenJFX 8<\/h2>\n\n<h3>Requirements<\/h3>\n\n<ul>\n<li>Mac OS >= 10.8<\/li>\n<li>XCode == 4.6.x<\/li>\n<li>X11\/XQuartz (provides freetype for JDK &amp; we use Xterm) <\/li>\n<li>Mercurial (version?)<\/li>\n<li>JDK >= 1.7.0_25<\/li>\n<li>Gradle >= 1.4 (currently tested with 1.4-1.6)<\/li>\n<\/ul>\n\n<h3>Step 1: Download OpenJDK 8 Sources<\/h3>\n\n<p>The OpenJDK project provides a good introduction to building OpenJDK. To really understand how to do it you should <a href=\"http:\/\/hg.openjdk.java.net\/jdk8\/jdk8\/raw-file\/tip\/README-builds.html\">read<\/a> it!<\/p>\n\n<p>To get the code open a terminal and type<\/p>\n\n<pre><code>#&gt; hg clone http:\/\/hg.openjdk.java.net\/jdk8\/jdk8 YourOpenJDK \n#&gt; cd YourOpenJDK \n#&gt; bash .\/get_source.sh\n<\/code><\/pre>\n\n<p>This will take a while.<\/p>\n\n<h3>Step 2: Download And Run JSelect<\/h3>\n\n<p><a href=\"https:\/\/mihosoft.eu\/?p=649\">Jselect<\/a> is a tool that allows to easily configure JDK installation paths. Just <a href=\"https:\/\/mihosoft.eu\/wp-content\/uploads\/2013\/06\/JSelect-0.3.zip\">download<\/a> and unpack it. It can be started by executing the <code>run.sh<\/code> script.<\/p>\n\n<p>Now run JSelect and specify your JDK 7 installation in that will be used as bootstrap JDK to build OpenJDK and the OpenJDK source location.<\/p>\n\n<p>In case of JDK 1.7.0.25 the path will be:<\/p>\n\n<pre><code>\/Library\/Java\/JavaVirtualMachines\/jdk1.7.0_25.jdk\/Contents\/Home\/\n<\/code><\/pre>\n\n<p>Now click <code>Open CMD<\/code>. JSelect will open a Xterm window which displays the selected Java version.<\/p>\n\n<p>Example output:<\/p>\n\n<pre><code>java version \"1.7.0_25\"\nJava(TM) SE Runtime Environment (build 1.7.0_25-b15)\nJava HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)\n\n#&gt;_\n<\/code><\/pre>\n\n<h3>Step 3: Compile OpenJDK 8<\/h3>\n\n<p>Make sure to install <code>Xcode 4.6.x<\/code> and to install its CLI (command line interface). If you have multiple version of Xcode it is necessary to select the correct one! This can be doe with the following command (example for version 4.6.3):<\/p>\n\n<pre><code>#&gt; sudo xcode-select --switch \/Applications\/Xcode4.6.3.app\/Contents\/Developer\n<\/code><\/pre>\n\n<p>Now it is time to finally compile the JDK:  <\/p>\n\n<pre><code>#&gt; java -version \njava version \"1.7.0_25\"\n\n#&gt; .\/configure \\\n\n--with-debug-level=release \\\n--with-milestone=\"1\" \\\n--with-boot-jdk=\/Library\/Java\/JavaVirtualMachines\/jdk1.7.0_25.jdk\/Contents\/Home\/ \\\n--with-build-number=109\n\n#&gt; make clean images\n<\/code><\/pre>\n\n<blockquote>\n  <p><strong>NOTE:<\/strong> change the bootstrap jdk folder if you use a different version than <code>JDK 1.7.0.25<\/code>.<\/p>\n<\/blockquote>\n\n<p>You may change the build number. I have chosen it to match the EA provided by Oracle.<\/p>\n\n<blockquote>\n  <p><strong>NOTE:<\/strong> if you get compile errors it is likely that you didn&#8217;t select the correct Xcode version or that something went wrong with selecting it. In this case it might help to uninstall the CLI by typing <code>sudo pkgutil --forget com.apple.pkg.DeveloperToolsCLI<\/code> and to install it again afterwards.<\/p>\n<\/blockquote>\n\n<h3>Step 4: Using the new OpenJDK<\/h3>\n\n<p>To test and use the new JDK, we use JSelect again. Select the location of the JDK 8 image:<\/p>\n\n<pre><code>YourOpenJDK\/build\/macosx-x86_64-normal-server-release\/images\/j2sdk-bundle\/jdk1.8.0.jdk\/Contents\/Home\/\n<\/code><\/pre>\n\n<blockquote>\n  <p><strong>NOTE:<\/strong> YourOpenJDK has to match the location from above when you checked out the code<\/p>\n<\/blockquote>\n\n<p>Now click <code>Open CMD<\/code>. A terminal window will open. If it shows the correct version number then you know that the PATH variable points to the OpenJDK installation.<\/p>\n\n<p>Example Output: <\/p>\n\n<pre><code>openjdk version \"1.8.0-internal\"\nOpenJDK Runtime Environment (build 1.8.0-internal-miho_2013...)\nOpenJDK 64-Bit Server VM (build 25.0-b54, mixed mode)\n\n#&gt;_\n<\/code><\/pre>\n\n<h3>Step 4: Downloading OpenJFX<\/h3>\n\n<p>Make sure to use the Xterm window from [Step 4][].<\/p>\n\n<p>On the OpenJFX page there is a good <a href=\"https:\/\/wiki.openjdk.java.net\/display\/OpenJFX\/Building+OpenJFX\">tutorial<\/a> on how to build it. It just misses some details about how to build with OpenJDK 8 and choosing the correct Xcode version. You should definitely read it!<\/p>\n\n<p>Before proceeding here it is important to choose the correct source branch. There is one called <code>master<\/code> that matches the version used for the weekly JDK builds provided by Oracle. The next option is the <code>controls<\/code> branch useful for working on bugfixes for controls etc. Finally, there is the <code>graphics<\/code> branch. I have tested the <code>master<\/code> and <code>graphics<\/code> branch. Both worked great for me.<\/p>\n\n<p>To clone the <code>graphics<\/code> branch type<\/p>\n\n<pre><code>#&gt; hg clone http:\/\/hg.openjdk.java.net\/openjfx\/8\/graphics\/rt rt-graphics\n<\/code><\/pre>\n\n<p>Also this will take some time.<\/p>\n\n<h3>Step 5: Configuring OpenJFX<\/h3>\n\n<p>The first thing to do is to create a file called <code>gradle.properties<\/code> inside the <code>rt-graphics<\/code> directory. You can also check the <code>gradle.properties.template<\/code> file that contains all possible options plus documentation.<\/p>\n\n<blockquote>\n  <p><strong>NOTE:<\/strong> in some tutorials people suggest to copy the <code>gradle.properties<\/code> file to the <code>$HOME\/.gradle<\/code> folder. Don&#8217;t do that! It is always better to keep the configuration as local as possible. If you think this is wrong that you probably know what you do. Go ahead \ud83d\ude42<\/p>\n<\/blockquote>\n\n<p>The content of <code>gradle.properties<\/code> should be<\/p>\n\n<pre><code>MACOSX_SDK_PATH = \/Applications\/Xcode4.6.3.app\/Contents\/Developer\/Platforms\/MacOSX.platform\/Developer\/SDKs\/MacOSX10.7.sdk\nBINARY_STUB=..\/stubs\/b109\/jfxrt.jar\n<\/code><\/pre>\n\n<p>This first line specifies that <code>10.7<\/code> shall be the OS X build sdk.<\/p>\n\n<blockquote>\n  <p><strong>Note:<\/strong> on 10.9 the 10.7 sdk might not be available. In this case please select 10.8.<\/p>\n<\/blockquote>\n\n<p>In the second line we specify the location of the binary stub <code>jfxrt.jar<\/code> file (use one from recent Java 8 EA builds). <\/p>\n\n<p>In <code>build.gradle<\/code> we specify build numbers again:<\/p>\n\n<pre><code>jfx.build.jdk.version=1.8.0\njfx.build.jdk.buildnum=110\njfx.build.jdk.buildnum.min=1\n<\/code><\/pre>\n\n<h2>Step 6: Building OpenJFX<\/h2>\n\n<p>Now it is time to build OpenJFX including native libraries:<\/p>\n\n<pre><code>#&gt; gradle -PBUILD_NATIVES=true -PBUILD_WEBKIT=true clean sdk\n<\/code><\/pre>\n\n<h2>Step 7: Copying OpenJFX To The OpenJDK Image<\/h2>\n\n<p>Disclaimer: I&#8217;m not a gradle expert! <\/p>\n\n<p>I decided to create a custom gradle task to complete the final task. Create a file <code>addToOpenjdk.gradle<\/code> with the following content (adjust paths to match your OpenJDK location):<\/p>\n\n<pre><code>task copyRTLibs(type: Copy) {\n    def JDK_PATH=\"YourOpenJDK\/build\/macosx-x86_64-normal-server-release\/images\/j2sdk-bundle\/jdk1.8.0.jdk\/Contents\/Home\/\"\n\n    from 'build\/mac-sdk\/rt\/lib'\n    into JDK_PATH+'\/jre\/lib'\n}\n\ntask copyLibs(type: Copy) {\n     def JDK_PATH=\"YourOpenJDK\/build\/macosx-x86_64-normal-server-release\/images\/j2sdk-bundle\/jdk1.8.0.jdk\/Contents\/Home\/\"\n\n     from 'build\/mac-sdk\/lib'\n     into JDK_PATH+'\/lib'\n}\n\ntask copyBin(type: Copy) {\n    def JDK_PATH=\"YourOpenJDK\/build\/macosx-x86_64-normal-server-release\/images\/j2sdk-bundle\/jdk1.8.0.jdk\/Contents\/Home\/\"\n\n    from 'build\/mac-sdk\/bin'\n    into JDK_PATH+'\/bin'\n}\n\n\ntask addToOpenJdk() &lt;&lt; {\n\n    System.out.println(\"JAVA: \"+System.getProperty(\"java.version\"));\n\n    tasks[\"copyRTLibs\"].execute()\n    tasks[\"copyLibs\"].execute()\n    tasks[\"copyBin\"].execute()\n\n}\n<\/code><\/pre>\n\n<p>Execute the task by typing<\/p>\n\n<pre><code>#&gt; gradle addToOpenJdk\n<\/code><\/pre>\n\n<h2>Conclusion &amp; Next Steps!<\/h2>\n\n<p>Congratulation! You have just created your own fully functional OpenJDK 8 release! The next part will cover App Store submission.<\/p>\n\n<p>Stay tuned and <a href=\"https:\/\/twitter.com\/intent\/user?screen_name=mihosoft\">follow me on Twitter<\/a><\/p>\n\n<p><strong>To be continued&#8230;<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>**[Update: 19.11.2013]: ** gradle script available that simplifies the process dramatically! Java 8 is a major update from a language perspective and also from a platform perspective. It brings new APIs and significant syntax improvements such as lambda expressions. JavaFX brings support for 3D nodes, highly improved Swing integration, new &#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[95,13,129,21],"tags":[44,131,98,101,99,100,96,24],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2P2yR-fx","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/mihosoft.eu\/index.php?rest_route=\/wp\/v2\/posts\/963"}],"collection":[{"href":"https:\/\/mihosoft.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mihosoft.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mihosoft.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mihosoft.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=963"}],"version-history":[{"count":23,"href":"https:\/\/mihosoft.eu\/index.php?rest_route=\/wp\/v2\/posts\/963\/revisions"}],"predecessor-version":[{"id":1008,"href":"https:\/\/mihosoft.eu\/index.php?rest_route=\/wp\/v2\/posts\/963\/revisions\/1008"}],"wp:attachment":[{"href":"https:\/\/mihosoft.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mihosoft.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mihosoft.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}