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