src/main/javadoc/overview.html
author Jaroslav Tulach <jaroslav.tulach@netbeans.org>
Sat, 15 Mar 2014 14:40:27 +0100
changeset 614 cf91336956b8
parent 611 20f8fa2750d6
child 615 b9d3832309ad
permissions -rw-r--r--
Few words about the IDE support or lack of it
jaroslav@550
     1
<!--
jaroslav@550
     2
jaroslav@550
     3
    DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
jaroslav@550
     4
jaroslav@551
     5
    Copyright 2013-2014 Oracle and/or its affiliates. All rights reserved.
jaroslav@550
     6
jaroslav@550
     7
    Oracle and Java are registered trademarks of Oracle and/or its affiliates.
jaroslav@550
     8
    Other names may be trademarks of their respective owners.
jaroslav@550
     9
jaroslav@550
    10
    The contents of this file are subject to the terms of either the GNU
jaroslav@550
    11
    General Public License Version 2 only ("GPL") or the Common
jaroslav@550
    12
    Development and Distribution License("CDDL") (collectively, the
jaroslav@550
    13
    "License"). You may not use this file except in compliance with the
jaroslav@550
    14
    License. You can obtain a copy of the License at
jaroslav@550
    15
    http://www.netbeans.org/cddl-gplv2.html
jaroslav@550
    16
    or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
jaroslav@550
    17
    specific language governing permissions and limitations under the
jaroslav@550
    18
    License.  When distributing the software, include this License Header
jaroslav@550
    19
    Notice in each file and include the License file at
jaroslav@550
    20
    nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
jaroslav@550
    21
    particular file as subject to the "Classpath" exception as provided
jaroslav@550
    22
    by Oracle in the GPL Version 2 section of the License file that
jaroslav@550
    23
    accompanied this code. If applicable, add the following below the
jaroslav@550
    24
    License Header, with the fields enclosed by brackets [] replaced by
jaroslav@550
    25
    your own identifying information:
jaroslav@550
    26
    "Portions Copyrighted [year] [name of copyright owner]"
jaroslav@550
    27
jaroslav@550
    28
    Contributor(s):
jaroslav@550
    29
jaroslav@550
    30
    The Original Software is NetBeans. The Initial Developer of the Original
jaroslav@551
    31
    Software is Oracle. Portions Copyright 2013-2014 Oracle. All Rights Reserved.
jaroslav@550
    32
jaroslav@550
    33
    If you wish your version of this file to be governed by only the CDDL
jaroslav@550
    34
    or only the GPL Version 2, indicate your decision by adding
jaroslav@550
    35
    "[Contributor] elects to include this software in this distribution
jaroslav@550
    36
    under the [CDDL or GPL Version 2] license." If you do not indicate a
jaroslav@550
    37
    single choice of license, a recipient has the option to distribute
jaroslav@550
    38
    your version of this file under either the CDDL, the GPL Version 2 or
jaroslav@550
    39
    to extend the choice of license to its licensees as provided above.
jaroslav@550
    40
    However, if you add GPL Version 2 code and therefore, elected the GPL
jaroslav@550
    41
    Version 2 license, then the option applies only if the new code is
jaroslav@550
    42
    made subject to such option by the copyright holder.
jaroslav@550
    43
jaroslav@550
    44
-->
jaroslav@541
    45
<!DOCTYPE html>
jaroslav@541
    46
<html>
jaroslav@541
    47
    <head>
jaroslav@541
    48
        <title>HTML for Java APIs</title>
jaroslav@541
    49
        <meta charset="UTF-8">
jaroslav@541
    50
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
jaroslav@541
    51
    </head>
jaroslav@541
    52
    <body>
jaroslav@541
    53
        <p>
jaroslav@543
    54
         Use Java to write application logic; Use HTML5 to render the UI; 
jaroslav@543
    55
         {@link net.java.html.json.Model Animate an HTML page from Java};
jaroslav@543
    56
         Use {@link net.java.html.json.OnReceive REST} or
jaroslav@543
    57
         <a href="net/java/html/json/doc-files/websockets.html">WebSockets</a>;
jaroslav@543
    58
         interact with <a href="net/java/html/js/package-summary.html">JavaScript</a>;
jaroslav@543
    59
         Get the best of both worlds!
jaroslav@543
    60
         
jaroslav@541
    61
         The goal of these APIs is to use full featured Java runtime 
jaroslav@568
    62
         (like real <a href="http://wiki.apidesign.org/wiki/HotSpot">HotSpot VM</a>), 
jaroslav@541
    63
         but still rely on a very lightweight rendering technology 
jaroslav@541
    64
         (so it can potentially fit 
jaroslav@541
    65
         <a href="http://bck2brwsr.apidesign.org">Bck2Brwsr</a> and definitely
jaroslav@541
    66
         to various types of phones). What can be more lightweight 
jaroslav@541
    67
         (from a browser perspective) than 
jaroslav@541
    68
         <a href="http://wiki.apidesign.org/wiki/HTML">HTML</a>!?
jaroslav@541
    69
         By default we use {@link net.java.html.boot.fx JavaFX's WebView} 
jaroslav@541
    70
         component to display the <a href="http://wiki.apidesign.org/wiki/HTML">HTML</a>. 
jaroslav@541
    71
         We eliminate the need to manipulate the DOM directly, 
jaroslav@541
    72
         there is a special {@link net.java.html.json Java to Knockout.js binding}. 
jaroslav@543
    73
         As a result the <a href="http://wiki.apidesign.org/wiki/Knockout4Java">HTML uses Knockout.js syntax</a>, 
jaroslav@541
    74
         yet the application code can be written in Java.
jaroslav@541
    75
        </p>
jaroslav@541
    76
        
jaroslav@541
    77
        <h3>Interesting Entry Points</h3>
jaroslav@541
    78
        
jaroslav@541
    79
        <p>Learn how to {@link net.java.html.json.Model animate an HTML page from Java}
jaroslav@541
    80
            without referencing single HTML element from the Java code.
jaroslav@541
    81
        </p>
jaroslav@541
    82
        <p>Use {@link net.java.html.json.OnReceive JSON} to communicate
jaroslav@541
    83
            with REST based server API.
jaroslav@541
    84
        </p>
jaroslav@541
    85
        <p>Use <a href="net/java/html/json/doc-files/websockets.html">WebSockets</a>
jaroslav@541
    86
            and JSON.
jaroslav@541
    87
        </p>
jaroslav@541
    88
        <p>Call JavaScript methods from Java and vice versa, via
jaroslav@541
    89
            <a href="net/java/html/js/package-summary.html">JavaScriptBody</a>.
jaroslav@541
    90
        </p>
jaroslav@541
    91
jaroslav@541
    92
        <h3>Getting Started</h3>
jaroslav@541
    93
jaroslav@541
    94
        There are many ways to start developing 
jaroslav@541
    95
        <a href="http://html.java.net">Html for Java</a> application. 
jaroslav@541
    96
        However to be sure one chooses the most recent setup, it is recommended
jaroslav@541
    97
        to switch to good old command line and use a 
jaroslav@541
    98
        <a href="http://wiki.apidesign.org/wiki/Knockout4Java">Maven archetype</a>
jaroslav@610
    99
        associated with every version of this project. Make sure at least 
jaroslav@610
   100
        <em>JDK7</em> is your installed Java and type:
jaroslav@541
   101
        <pre>      
jaroslav@541
   102
$ mvn archetype:generate \
jaroslav@541
   103
 -DarchetypeGroupId=org.apidesign.html \
jaroslav@541
   104
 -DarchetypeArtifactId=knockout4j-archetype \
jaroslav@608
   105
 -DarchetypeVersion=0.7.5 <em># or newer version, if available</em>
jaroslav@541
   106
        </pre>
jaroslav@611
   107
        Answer few questions (for example choose myfirstbrwsrpage as artifactId) 
jaroslav@611
   108
        and then you can:
jaroslav@541
   109
        <pre>
jaroslav@541
   110
$ cd myfirstbrwsrpage
jaroslav@541
   111
$ mvn process-classes exec:java
jaroslav@541
   112
        </pre>
jaroslav@541
   113
        In a few seconds (or minutes if 
jaroslav@541
   114
        <a href="http://wiki.apidesign.org/wiki/Maven">Maven</a>
jaroslav@541
   115
        decides to download the whole Internet of dependencies) you should 
jaroslav@611
   116
        see a sample Hello World application rendered in a 
jaroslav@611
   117
        <a href="http://wiki.apidesign.org/wiki/JavaFX">JavaFX</a>
jaroslav@611
   118
        web view component (that of course requires your JDK to come
jaroslav@611
   119
        with <a href="http://wiki.apidesign.org/wiki/JavaFX">JavaFX</a>; 
jaroslav@611
   120
        <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">JDK7 
jaroslav@611
   121
            and JDK8 from Oracle</a> contain everything that is needed). 
jaroslav@611
   122
        The generated application is built around one 
jaroslav@611
   123
        Java source (uses the {@link net.java.html.json.Model} annotation to
jaroslav@611
   124
        auto-generate another <code>Data.java</code> class during compilation)
jaroslav@611
   125
        and one HTML file (uses the <a href="http://knockoutjs.com">Knockout</a>
jaroslav@611
   126
        syntax to <code>data-bind</code> the HTML elements to the 
jaroslav@611
   127
        generated <code>Data</code> model):
jaroslav@541
   128
        <pre>
jaroslav@541
   129
$ ls src/main/java/**/DataModel.java
jaroslav@541
   130
$ ls src/main/webapp/pages/index.html
jaroslav@541
   131
        </pre>
jaroslav@611
   132
        That is all you need to get started. Play with the sources, 
jaroslav@611
   133
        modify them and enjoy
jaroslav@541
   134
        <a href="http://html.java.net">Html for Java</a>!
jaroslav@541
   135
        
jaroslav@614
   136
        <h2>IDE Support</h2>
jaroslav@614
   137
        
jaroslav@614
   138
        <p>
jaroslav@614
   139
            This API is part of <a target="_blank"
jaroslav@614
   140
            href="http://netbeans.org">NetBeans.org</a> project and as such
jaroslav@614
   141
            it works naturally with the <a target="_blank"
jaroslav@614
   142
            href="https://netbeans.org/features/index.html">NetBeans IDE</a>.
jaroslav@614
   143
            On the other hand, the API is using nothing NetBeans specific,
jaroslav@614
   144
            it builds on standard Java6 APIs and as such it shall work fine
jaroslav@614
   145
            in any IDE.
jaroslav@614
   146
        </p>
jaroslav@614
   147
        
jaroslav@614
   148
        <p>
jaroslav@614
   149
            A lot of work is done by 
jaroslav@614
   150
            <a href="http://wiki.apidesign.org/wiki/AnnotationProcessor">
jaroslav@614
   151
            annotation processors</a>
jaroslav@614
   152
            that generate various boiler plate code during compilation. This
jaroslav@614
   153
            is a standard part of Java since JDK6, but for example Eclipse
jaroslav@614
   154
            is known not to deal with processors well and developers using
jaroslav@614
   155
            it need to be careful. IntelliJ users hasn't reported any issues
jaroslav@614
   156
            and of course, NetBeans IDE support for 
jaroslav@614
   157
            <a href="http://wiki.apidesign.org/wiki/AnnotationProcessor">processors</a>
jaroslav@614
   158
            is outstanding.
jaroslav@614
   159
        </p>
jaroslav@614
   160
        
jaroslav@614
   161
        <p>
jaroslav@614
   162
            When using {@link net.java.html.js.JavaScriptBody} annotation, it is
jaroslav@614
   163
            useful to do a bit of post processing of classes. There is a
jaroslav@614
   164
            <a href="http://wiki.apidesign.org/wiki/Maven">Maven</a> 
jaroslav@614
   165
            plugin for that.
jaroslav@614
   166
            NetBeans IDE will invoke it when doing a build. Other IDEs may 
jaroslav@614
   167
            need some hint to do so. 
jaroslav@614
   168
            Anyway: If one does not see all (generated) sources or is getting
jaroslav@614
   169
            {@link java.lang.LinkageError}s when executing the application, 
jaroslav@614
   170
            switch to command line and do clean build
jaroslav@614
   171
            from there:
jaroslav@614
   172
        </p>
jaroslav@614
   173
        <pre>$ mvn clean install</pre>
jaroslav@614
   174
        <p>
jaroslav@614
   175
            If that succeeds, your IDE of choice will hopefully
jaroslav@614
   176
            pick the generated sources up and present the result of the build 
jaroslav@614
   177
            properly. If not, 
jaroslav@614
   178
            <a href="https://netbeans.org/downloads/">download NetBeans</a>, 
jaroslav@614
   179
            you will be pleasantly 
jaroslav@614
   180
            surprised - for example with our excellent 
jaroslav@614
   181
            <a href="net/java/html/js/package-summary.html#debugging">Java/JavaScript 
jaroslav@614
   182
            debugging</a> support.
jaroslav@614
   183
        </p>
jaroslav@614
   184
        
jaroslav@607
   185
        <h2>Other Resources</h2>
jaroslav@607
   186
        
jaroslav@607
   187
        <img src="net/java/html/json/doc-files/DukeHTML.png" width="256" height="184" alt="Duke and HTML5. Together at last!" align="right"/>
jaroslav@607
   188
        
jaroslav@607
   189
        The javadoc for latest and previous versions is also available
jaroslav@607
   190
        online:
jaroslav@607
   191
        <ul>
jaroslav@607
   192
            <li>Current <a target="_blank" href="http://bits.netbeans.org/html+java/dev/">development</a> version
jaroslav@607
   193
            <li>Version <a target="_blank" href="http://bits.netbeans.org/html+java/0.7.5">0.7.5</a>
jaroslav@607
   194
        </ul>
jaroslav@541
   195
    </body>
jaroslav@541
   196
</html>