3 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5 Copyright 2013-2014 Oracle and/or its affiliates. All rights reserved.
7 Oracle and Java are registered trademarks of Oracle and/or its affiliates.
8 Other names may be trademarks of their respective owners.
10 The contents of this file are subject to the terms of either the GNU
11 General Public License Version 2 only ("GPL") or the Common
12 Development and Distribution License("CDDL") (collectively, the
13 "License"). You may not use this file except in compliance with the
14 License. You can obtain a copy of the License at
15 http://www.netbeans.org/cddl-gplv2.html
16 or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
17 specific language governing permissions and limitations under the
18 License. When distributing the software, include this License Header
19 Notice in each file and include the License file at
20 nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
21 particular file as subject to the "Classpath" exception as provided
22 by Oracle in the GPL Version 2 section of the License file that
23 accompanied this code. If applicable, add the following below the
24 License Header, with the fields enclosed by brackets [] replaced by
25 your own identifying information:
26 "Portions Copyrighted [year] [name of copyright owner]"
30 The Original Software is NetBeans. The Initial Developer of the Original
31 Software is Oracle. Portions Copyright 2013-2014 Oracle. All Rights Reserved.
33 If you wish your version of this file to be governed by only the CDDL
34 or only the GPL Version 2, indicate your decision by adding
35 "[Contributor] elects to include this software in this distribution
36 under the [CDDL or GPL Version 2] license." If you do not indicate a
37 single choice of license, a recipient has the option to distribute
38 your version of this file under either the CDDL, the GPL Version 2 or
39 to extend the choice of license to its licensees as provided above.
40 However, if you add GPL Version 2 code and therefore, elected the GPL
41 Version 2 license, then the option applies only if the new code is
42 made subject to such option by the copyright holder.
48 <title>HTML for Java APIs</title>
49 <meta charset="UTF-8">
50 <meta name="viewport" content="width=device-width, initial-scale=1.0">
54 Use Java to write application logic; Use HTML5 to render the UI;
55 {@link net.java.html.json.Model Animate an HTML page from Java};
56 Use {@link net.java.html.json.OnReceive REST} or
57 <a href="net/java/html/json/doc-files/websockets.html">WebSockets</a>;
58 interact with <a href="net/java/html/js/package-summary.html">JavaScript</a>;
59 Get the best of both worlds!
61 The goal of these APIs is to use full featured Java runtime
62 (e.g. real <a href="http://wiki.apidesign.org/wiki/HotSpot">HotSpot VM</a>),
63 but still rely on a very lightweight rendering technology
64 (so it can potentially fit
65 <a href="http://bck2brwsr.apidesign.org">Bck2Brwsr</a> and definitely
66 to various types of phones). What can be more lightweight
67 (from a browser perspective) than
68 <a href="http://wiki.apidesign.org/wiki/HTML">HTML</a>!?
69 By default we use {@link net.java.html.boot.fx JavaFX's WebView}
70 component to display the <a href="http://wiki.apidesign.org/wiki/HTML">HTML</a>.
71 We eliminate the need to manipulate the DOM directly,
72 there is a special {@link net.java.html.json Java to Knockout.js binding}.
73 As a result the <a href="http://wiki.apidesign.org/wiki/Knockout4Java">HTML uses Knockout.js syntax</a>,
74 yet the application code can be written in Java.
77 <h3>Interesting Entry Points</h3>
79 <p>Learn how to {@link net.java.html.json.Model animate an HTML page from Java}
80 without referencing single HTML element from the Java code.
82 <p>Use {@link net.java.html.json.OnReceive JSON} to communicate
83 with REST based server API.
85 <p>Use <a href="net/java/html/json/doc-files/websockets.html">WebSockets</a>
88 <p>Call JavaScript methods from Java and vice versa, via
89 <a href="net/java/html/js/package-summary.html">JavaScriptBody</a>.
92 <h3>Getting Started</h3>
94 There are many ways to start developing
95 <a href="http://html.java.net">Html for Java</a> application.
96 However to be sure one chooses the most recent setup, it is recommended
97 to switch to good old command line and use a
98 <a href="http://wiki.apidesign.org/wiki/Knockout4Java">Maven archetype</a>
99 associated with every version of this project. Just type:
101 $ mvn archetype:generate \
102 -DarchetypeGroupId=org.apidesign.html \
103 -DarchetypeArtifactId=knockout4j-archetype \
104 -DarchetypeVersion=x.y
106 Answer few questions (for example choose myfirstbrwsrpage as artifactId) and then you can:
108 $ cd myfirstbrwsrpage
109 $ mvn process-classes exec:java
111 In a few seconds (or minutes if
112 <a href="http://wiki.apidesign.org/wiki/Maven">Maven</a>
113 decides to download the whole Internet of dependencies) you should
114 see a sample Hello World application. It is basically composed from one
115 Java and one HTML file:
117 $ ls src/main/java/**/DataModel.java
118 $ ls src/main/webapp/pages/index.html
120 Play with them, modify them and enjoy
121 <a href="http://html.java.net">Html for Java</a>!
124 <img src="net/java/html/json/doc-files/DukeHTML.png" width="640" height="480" alt="Duke and HTML5. Together at last!"/>