├── .gitignore
├── LICENSE
├── README.md
├── bck2brwsr
├── .gitignore
├── client-web
│ ├── nbactions.xml
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── assembly
│ │ │ ├── bck2brwsr.xml
│ │ │ └── teavm.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── athaydes
│ │ │ └── BrowserMain.java
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── athaydes
│ │ └── IntegrationTest.java
├── client
│ ├── nbactions.xml
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── assembly
│ │ │ ├── javafx.xml
│ │ │ └── webpages.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── athaydes
│ │ │ │ ├── DataModel.java
│ │ │ │ └── Main.java
│ │ └── webapp
│ │ │ └── pages
│ │ │ ├── index.css
│ │ │ └── index.html
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── athaydes
│ │ └── DataModelTest.java
├── js
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── com
│ │ │ └── athaydes
│ │ │ └── js
│ │ │ └── PlatformServices.java
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── athaydes
│ │ └── js
│ │ └── JsInteractionTest.java
└── pom.xml
├── cheerpj
├── .gitignore
├── Makefile
├── cheerpjswing
│ ├── .gitignore
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── Main.java
└── index.html
├── dart-counter
├── .gitignore
├── CHANGELOG.md
├── README.md
├── analysis_options.yaml
├── pubspec.yaml
└── web
│ ├── favicon.ico
│ ├── index.html
│ ├── main.dart
│ └── styles.css
├── gwt-app
├── .classpath
├── .gitignore
├── .project
├── GwtApp.launch
├── README.txt
├── build.xml
├── src
│ └── com
│ │ └── athaydes
│ │ ├── GwtApp.gwt.xml
│ │ └── client
│ │ └── GwtApp.java
└── war
│ ├── GwtApp.css
│ ├── GwtApp.html
│ ├── WEB-INF
│ └── web.xml
│ └── favicon.ico
├── jsweet
├── ..gitignore.swp
├── .gitignore
├── LICENSE
├── README.md
├── pom.xml
├── src
│ └── main
│ │ └── java
│ │ └── quickstart
│ │ └── QuickStart.java
└── webapp
│ ├── index.html
│ └── logo.png
├── react
├── counter.js
├── index.html
├── index.js
├── react-dom.production.min.js
└── react.production.min.js
├── teavm-latest
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── athaydes
│ │ └── Client.java
│ └── webapp
│ ├── WEB-INF
│ └── web.xml
│ └── index.html
├── teavm
├── .gitignore
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── athaydes
│ │ └── Client.java
│ └── webapp
│ ├── WEB-INF
│ └── web.xml
│ └── index.html
└── vaadin
├── .gitignore
├── LICENSE.md
├── README.md
├── pom.xml
└── src
└── main
├── java
└── com
│ └── example
│ └── test
│ └── MainView.java
├── resources
└── banner.txt
└── webapp
├── frontend
├── src
│ └── README
└── styles
│ └── README
└── icons
└── icon.png
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .idea/
3 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # JVM alternatives to JS
2 |
3 | This repo contains different implementations of a simple counter application in the following Java-based
4 | technologies:
5 |
6 | * CheerpJ
7 | * GWT
8 | * JSweet
9 | * TeaVM
10 | * Vaadin Flow
11 |
12 | > bck2brwsr example is broken - I couldn't get it working.
13 |
14 | For comparison, it also contains the following other implementations:
15 |
16 | * React.js
17 | * Dart
18 |
19 | Code for blog post: [Comparing JVM alternatives to JavaScript](https://renato.athaydes.com/posts/comparing-jvm-alternatives-to-js.html).
20 |
21 |
--------------------------------------------------------------------------------
/bck2brwsr/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 |
--------------------------------------------------------------------------------
/bck2brwsr/client-web/nbactions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | run
5 |
6 | jar
7 |
8 |
9 | package
10 | bck2brwsr:show
11 |
12 |
13 | true
14 |
15 |
16 |
17 | debug
18 |
19 | jar
20 |
21 |
22 | package
23 | bck2brwsr:show
24 |
25 |
26 | true
27 | NONE
28 | maven
29 |
30 |
31 |
32 | CUSTOM-bck2brwsr-show
33 | Run in a Browser
34 |
35 | package
36 | bck2brwsr:show
37 |
38 |
39 | true
40 | NONE
41 |
42 |
43 |
44 | CUSTOM-bck2brwsr-web
45 | Package for website
46 |
47 | clean
48 | package
49 |
50 |
51 | true
52 |
53 |
54 |
55 | CUSTOM-teavm-show
56 | Run in a Browser via TeaVM
57 |
58 | package
59 | bck2brwsr:show
60 |
61 |
62 | teavm
63 |
64 |
65 | true
66 |
67 |
68 |
69 | CUSTOM-teavm-show
70 | Debug in a Browser via TeaVM
71 |
72 | package
73 | bck2brwsr:show
74 |
75 |
76 | teavm
77 |
78 |
79 | true
80 | true
81 |
82 |
83 |
84 | CUSTOM-teavm-web
85 | Package for website via TeaVM
86 |
87 | clean
88 | package
89 |
90 |
91 | true
92 |
93 |
94 | teavm
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/bck2brwsr/client-web/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 |
7 | com.athaydes
8 | bck2brwsr-pom
9 | 1.0-SNAPSHOT
10 |
11 |
12 | com.athaydes
13 | bck2brwsr-web
14 | 1.0-SNAPSHOT
15 | jar
16 |
17 | bck2brwsr Client for Web
18 |
19 |
20 | none
21 | com.athaydes.BrowserMain
22 | initialize bck2brwsr -->
23 | <script type="text/javascript" src="bck2brwsr.js"></script>
24 | <script>
25 | var vm = bck2brwsr('bck2brwsr-web.js');
26 | var c = vm.loadClass('com.athaydes.BrowserMain');
27 | c.invoke('main');
28 | </script>
29 | <!-- end of initialization
30 |
31 |
32 |
33 |
34 | org.netbeans.html
35 | html4j-maven-plugin
36 | ${net.java.html.version}
37 |
38 |
39 | js-classes
40 |
41 | process-js-annotations
42 |
43 |
44 |
45 |
46 |
47 | org.apache.maven.plugins
48 | maven-compiler-plugin
49 | 2.3.2
50 |
51 | 1.7
52 | 1.7
53 |
54 | netbeans.ignore.jdk.bootclasspath
55 |
56 |
57 |
58 |
59 | org.apache.maven.plugins
60 | maven-jar-plugin
61 | 2.4
62 |
63 |
64 |
65 | ${project.mainclass}
66 | true
67 | lib/
68 | false
69 |
70 |
71 |
72 |
73 |
74 | org.apidesign.bck2brwsr
75 | bck2brwsr-maven-plugin
76 | ${bck2brwsr.version}
77 |
78 |
79 |
80 | brwsr
81 | aot
82 |
83 |
84 |
85 |
86 | ${bck2brwsr.obfuscationlevel}
87 | ${project.build.directory}/${project.build.finalName}-bck2brwsr/public_html/
88 | index.html
89 | lib
90 | ${project.build.directory}/bck2brwsr-web.js
91 |
92 | ${project.mainclass}
93 |
94 |
95 |
96 |
97 | maven-assembly-plugin
98 | 2.4
99 |
100 |
101 | distro-assembly
102 | package
103 |
104 | single
105 |
106 |
107 |
108 | src/main/assembly/bck2brwsr.xml
109 |
110 |
111 |
112 |
113 |
114 |
115 | org.apache.maven.plugins
116 | maven-dependency-plugin
117 | 2.9
118 |
119 |
120 | unpack
121 | process-resources
122 |
123 | unpack-dependencies
124 |
125 |
126 |
127 |
128 | zip
129 | webpages
130 | true
131 | target/web/pages
132 | */**
133 | ${project.groupId}
134 |
135 |
136 |
137 | org.apache.maven.plugins
138 | maven-surefire-plugin
139 | 2.19.1
140 |
141 | com.dukescript.api:junit-osgi
142 |
143 | false
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 | com.athaydes
152 | bck2brwsr
153 | ${project.version}
154 |
155 |
156 | org.netbeans.html
157 | net.java.html.boot.fx
158 |
159 |
160 |
161 |
162 | org.apidesign.bck2brwsr
163 | emul
164 | ${bck2brwsr.version}
165 | rt
166 |
167 |
168 | org.netbeans.html
169 | net.java.html.boot
170 | ${net.java.html.version}
171 |
172 |
173 | asm
174 | org.ow2.asm
175 |
176 |
177 |
178 |
179 | org.apidesign.bck2brwsr
180 | emul
181 | ${bck2brwsr.version}
182 | bck2brwsr
183 | provided
184 |
185 |
186 | org.apidesign.bck2brwsr
187 | ko-bck2brwsr
188 | ${bck2brwsr.version}
189 | bck2brwsr
190 | provided
191 |
192 |
193 | com.athaydes
194 | bck2brwsr-js
195 | ${project.version}
196 | bck2brwsr
197 | provided
198 | jar
199 |
200 |
201 |
202 |
203 |
204 | com.dukescript.api
205 | junit-osgi
206 | test
207 |
208 |
209 | com.dukescript.api
210 | junit-browser-runner
211 | test
212 |
213 |
214 |
215 |
216 | org.netbeans.html
217 | net.java.html.boot.fx
218 | ${net.java.html.version}
219 | test
220 |
221 |
222 | com.oracle
223 | javafx
224 |
225 |
226 |
227 |
228 | org.openjfx
229 | javafx-web
230 | ${openjfx.version}
231 | test
232 |
233 |
234 |
235 |
236 | org.apidesign.bck2brwsr
237 | launcher.http
238 | ${bck2brwsr.version}
239 | test
240 | jar
241 |
242 |
243 | com.dukescript.api
244 | junit-browser-runner
245 | ${junit.browser.version}
246 | test
247 | bck2brwsr
248 | jar
249 |
250 |
251 | org.netbeans.html
252 | net.java.html
253 |
254 |
255 | org.netbeans.html
256 | net.java.html.boot
257 |
258 |
259 | org.apidesign.bck2brwsr
260 | emul
261 |
262 |
263 |
264 |
265 |
266 |
267 | teavm
268 |
269 | 0.4.0
270 | false
271 | initialize TeaVM -->
272 | <script type="text/javascript" src="teavm.js"></script>
273 | <script>
274 | main();
275 | </script>
276 | <!-- end of initialization
277 |
278 |
279 |
280 |
281 | org.netbeans.html
282 | ko4j
283 | ${net.java.html.version}
284 |
285 |
286 |
287 |
288 |
289 | org.teavm
290 | teavm-maven-plugin
291 | ${teavm.version}
292 |
293 |
294 | org.teavm
295 | teavm-classlib
296 | ${teavm.version}
297 |
298 |
300 |
301 | org.teavm
302 | teavm-html4j
303 | ${teavm.version}
304 |
305 |
306 |
307 |
308 | generate-teavm
309 |
310 | compile
311 |
312 | process-classes
313 |
314 | ${project.mainclass}
315 | ${teavm.debug}
316 | ${teavm.debug}
317 | ${teavm.debug}
318 |
319 | false
320 |
321 | false
322 |
323 | MERGED
324 |
325 | teavm.js
326 | ${project.build.directory}/teavm
327 |
333 |
334 |
335 |
336 |
337 |
338 | maven-assembly-plugin
339 | 2.4
340 |
341 |
342 | distro-assembly
343 | package
344 |
345 | single
346 |
347 |
348 |
349 | src/main/assembly/teavm.xml
350 |
351 |
352 |
353 |
354 |
355 |
356 | org.apidesign.bck2brwsr
357 | bck2brwsr-maven-plugin
358 | ${bck2brwsr.version}
359 |
360 |
361 |
362 | brwsr
363 |
364 |
365 |
366 |
367 | ${project.build.directory}/${project.build.finalName}-teavm/public_html/
368 | index.html
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
--------------------------------------------------------------------------------
/bck2brwsr/client-web/src/main/assembly/bck2brwsr.xml:
--------------------------------------------------------------------------------
1 |
2 |
27 |
29 |
30 | bck2brwsr
31 |
32 | zip
33 | dir
34 |
35 | public_html
36 |
37 |
38 | target/web/pages
39 | /
40 |
41 | index.html
42 |
43 |
44 |
45 | target/web/pages
46 | /
47 | true
48 |
49 | index.html
50 |
51 |
52 |
53 | ${project.build.directory}
54 | /
55 |
56 | *.js
57 | lib/*.js
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/bck2brwsr/client-web/src/main/assembly/teavm.xml:
--------------------------------------------------------------------------------
1 |
2 |
27 |
29 |
30 | teavm
31 |
32 | zip
33 | dir
34 |
35 | public_html
36 |
37 |
38 | target/web/pages
39 | /
40 |
41 | index.html
42 |
43 |
44 |
45 | target/web/pages
46 | /
47 | true
48 |
49 | index.html
50 |
51 |
52 |
53 | ${project.build.directory}/teavm/
54 | /
55 | false
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/bck2brwsr/client-web/src/main/java/com/athaydes/BrowserMain.java:
--------------------------------------------------------------------------------
1 | package com.athaydes;
2 |
3 | import com.athaydes.js.PlatformServices;
4 |
5 | public class BrowserMain {
6 | private BrowserMain() {
7 | }
8 |
9 | public static void main(String... args) throws Exception {
10 | Main.onPageLoad(new HTML5Services());
11 | }
12 |
13 | private static final class HTML5Services extends PlatformServices {
14 | // default behavior is enough for now
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/bck2brwsr/client-web/src/test/java/com/athaydes/IntegrationTest.java:
--------------------------------------------------------------------------------
1 | package com.athaydes;
2 |
3 | import net.java.html.junit.BrowserRunner;
4 | import net.java.html.junit.HTMLContent;
5 | import static org.junit.Assert.assertEquals;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 |
9 | /** Tests for behavior of your application in real systems. The {@link BrowserRunner}
10 | * selects all possible presenters from your pom.xml and
11 | * runs the tests inside of them. By default there are two:
12 | *
13 | *
JavaFX WebView presenter - verifies behavior in HotSpot JVM
14 | *
Bck2Brwsr presenter - runs the test in a pluginless browser
15 | *
16 | *
17 | * See your pom.xml dependency section for details.
18 | */
19 | @RunWith(BrowserRunner.class)
20 | @HTMLContent(
21 | "
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/bck2brwsr/client/src/test/java/com/athaydes/DataModelTest.java:
--------------------------------------------------------------------------------
1 | package com.athaydes;
2 |
3 | import net.java.html.junit.BrowserRunner;
4 | import static org.junit.Assert.assertEquals;
5 | import org.junit.runner.RunWith;
6 | import org.junit.Test;
7 |
8 | /** Tests for behavior of your application in isolation. Verify
9 | * behavior of your MVVC code in a unit test.
10 | */
11 | @RunWith(BrowserRunner.class)
12 | public class DataModelTest {
13 | @Test public void testUIModelWithoutUI() {
14 | Data model = new Data();
15 | model.setMessage("Hello World!");
16 |
17 | java.util.List arr = model.getWords();
18 | assertEquals("Six words always", arr.size(), 6);
19 | assertEquals("Hello is the first word", "Hello", arr.get(0));
20 | assertEquals("World is the second word", "World!", arr.get(1));
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/bck2brwsr/js/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | com.athaydes
6 | bck2brwsr-pom
7 | 1.0-SNAPSHOT
8 |
9 |
10 | com.athaydes
11 | bck2brwsr-js
12 | 1.0-SNAPSHOT
13 | bundle
14 |
15 | bck2brwsr JavaScript Libraries
16 |
17 |
18 | none
19 |
20 |
21 |
22 |
23 | org.apache.felix
24 | maven-bundle-plugin
25 | 2.4.0
26 | true
27 |
28 |
29 | com.athaydes.js
30 | com.athaydes.js
31 |
32 |
33 |
34 |
35 | org.netbeans.html
36 | html4j-maven-plugin
37 | ${net.java.html.version}
38 |
39 |
40 | js-classes
41 |
42 | process-js-annotations
43 |
44 |
45 |
46 |
47 |
48 | org.apache.maven.plugins
49 | maven-compiler-plugin
50 | 2.3.2
51 |
52 | 1.7
53 | 1.7
54 |
55 |
56 |
57 | org.apache.maven.plugins
58 | maven-surefire-plugin
59 | 2.19.1
60 |
61 | com.dukescript.api:junit-osgi
62 |
63 | true
64 |
65 |
66 |
67 |
68 | org.apidesign.bck2brwsr
69 | bck2brwsr-maven-plugin
70 | ${bck2brwsr.version}
71 |
72 |
73 |
74 | library
75 |
76 |
77 |
78 |
79 | NONE
80 |
81 |
82 |
83 |
84 |
85 |
86 | org.netbeans.html
87 | net.java.html.boot
88 | ${net.java.html.version}
89 |
90 |
91 | com.dukescript.api
92 | junit-osgi
93 | test
94 |
95 |
96 | com.dukescript.api
97 | junit-browser-runner
98 | test
99 |
100 |
101 |
102 |
103 | org.netbeans.html
104 | net.java.html.boot.script
105 | ${net.java.html.version}
106 | test
107 | jar
108 |
109 |
110 |
135 |
136 |
137 |
--------------------------------------------------------------------------------
/bck2brwsr/js/src/main/java/com/athaydes/js/PlatformServices.java:
--------------------------------------------------------------------------------
1 | package com.athaydes.js;
2 |
3 | import net.java.html.js.JavaScriptBody;
4 |
5 | /** Use {@link JavaScriptBody} annotation on methods to
6 | * directly interact with JavaScript. See
7 | * http://bits.netbeans.org/html+java/1.3/net/java/html/js/package-summary.html
8 | * to understand how.
9 | */
10 | public class PlatformServices {
11 | /**
12 | * Reads a value from a persistent storage.
13 | * @param key the identification for the value
14 | * @return the value or null if not found
15 | */
16 | public String getPreferences(String key) {
17 | return getPreferencesImpl(key);
18 | }
19 |
20 | /**
21 | * Puts a value into the persitent storage.
22 | * @param key the identification for the value
23 | * @param value the value to store
24 | */
25 | public void setPreferences(String key, String value) {
26 | setPreferencesImpl(key, value);
27 | }
28 |
29 | /**
30 | * Shows confirmation dialog to the user.
31 | *
32 | * @param msg the message
33 | * @param callback called back when the use accepts (can be null)
34 | */
35 | public void confirmByUser(String msg, Runnable callback) {
36 | confirmImpl(msg, callback);
37 | }
38 |
39 | /**
40 | * Obtains size of the screen.
41 | * @return array with two numbers: width and height
42 | */
43 | public int[] getScreenSize() {
44 | Object[] size = screenSizeImpl();
45 | return new int[] {
46 | ((Number)size[0]).intValue(),
47 | ((Number)size[1]).intValue(),
48 | };
49 | }
50 |
51 | @JavaScriptBody(args = { "key" }, body =
52 | "if (!window.localStorage) return null;\n" +
53 | "return window.localStorage.getItem(key);\n"
54 | )
55 | private static native String getPreferencesImpl(String key);
56 |
57 | @JavaScriptBody(args = { "key", "value" }, body =
58 | "if (!window.localStorage) return;\n" +
59 | "window.localStorage.setItem(key, value);\n"
60 | )
61 | private static native void setPreferencesImpl(String key, String value);
62 |
63 | /**
64 | * Shows confirmation dialog to the user.
65 | *
66 | * @param msg the message
67 | * @param callback called back when the use accepts (can be null)
68 | */
69 | @JavaScriptBody(
70 | args = {"msg", "callback"},
71 | javacall = true,
72 | body = "if (confirm(msg)) {\n"
73 | + " callback.@java.lang.Runnable::run()();\n"
74 | + "}\n"
75 | )
76 | static native void confirmImpl(String msg, Runnable callback);
77 |
78 | @JavaScriptBody(
79 | args = {}, body
80 | = "var w = window,\n"
81 | + " d = document,\n"
82 | + " e = d.documentElement,\n"
83 | + " g = d.getElementsByTagName('body')[0],\n"
84 | + " x = w.innerWidth || e.clientWidth || g.clientWidth,\n"
85 | + " y = w.innerHeight|| e.clientHeight|| g.clientHeight;\n"
86 | + "\n"
87 | + "return [x, y];\n"
88 | )
89 | static native Object[] screenSizeImpl();
90 | }
91 |
--------------------------------------------------------------------------------
/bck2brwsr/js/src/test/java/com/athaydes/js/JsInteractionTest.java:
--------------------------------------------------------------------------------
1 | package com.athaydes.js;
2 |
3 | import net.java.html.junit.BrowserRunner;
4 | import static org.junit.Assert.assertEquals;
5 | import org.junit.Test;
6 | import org.junit.runner.RunWith;
7 |
8 | /** Tests for behavior of @JavaScriptBody methods. The {@link BrowserRunner}
9 | * selects all possible presenters from your pom.xml and
10 | * runs the tests inside of them.
11 | *
12 | * See your pom.xml dependency section for details.
13 | */
14 | @RunWith(BrowserRunner.class)
15 | public class JsInteractionTest {
16 | @Test
17 | public void emptyTest() {
18 | }
19 |
20 | @Test
21 | public void testCallbackFromJavaScript() throws Exception {
22 | class R implements Runnable {
23 | int called;
24 |
25 | @Override
26 | public void run() {
27 | called++;
28 | }
29 | }
30 | R callback = new R();
31 |
32 | final PlatformServices services = new PlatformServices();
33 | services.confirmByUser("Hello", callback);
34 |
35 | assertEquals("One immediate callback", callback.called, 1);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/bck2brwsr/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.athaydes
7 | bck2brwsr-pom
8 | 1.0-SNAPSHOT
9 | pom
10 |
11 | bck2brwsr
12 |
13 | client
14 | client-web
15 | js
16 |
17 |
18 | 1.5.1
19 | 11
20 | 0.30
21 | MINIMAL
22 | 1.0
23 | 2.13
24 | 1.5.2
25 | false
26 | UTF-8
27 |
28 |
29 |
30 |
31 | com.dukescript.api
32 | junit-osgi
33 | test
34 | 4.12
35 |
36 |
37 | com.dukescript.api
38 | junit-browser-runner
39 | ${junit.browser.version}
40 | test
41 | jar
42 |
43 |
44 | org.netbeans.html
45 | net.java.html
46 |
47 |
48 | org.netbeans.html
49 | net.java.html.boot
50 |
51 |
52 | org.apidesign.bck2brwsr
53 | emul
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | org.apache.maven.plugins
63 | maven-compiler-plugin
64 | 3.8.0
65 |
66 | 1.8
67 | 1.8
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/cheerpj/.gitignore:
--------------------------------------------------------------------------------
1 | *.jar
2 | *.jar.js
3 |
--------------------------------------------------------------------------------
/cheerpj/Makefile:
--------------------------------------------------------------------------------
1 | all: swing.jar.js
2 |
3 | swing.jar:
4 | cd cheerpjswing && mvn package
5 | cp cheerpjswing/target/cheerpj-swing-1.0-SNAPSHOT.jar swing.jar
6 |
7 | swing.jar.js: swing.jar
8 | ~/cheerpj_1.3/cheerpjfy.py swing.jar
9 |
10 | clean:
11 | cd cheerpjswing && mvn clean
12 | rm -rf swing.jar swing.jar.js
--------------------------------------------------------------------------------
/cheerpj/cheerpjswing/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 |
--------------------------------------------------------------------------------
/cheerpj/cheerpjswing/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.athaydes
8 | cheerpj-swing
9 | 1.0-SNAPSHOT
10 |
11 |
12 |
13 | maven-compiler-plugin
14 | 3.1
15 |
16 | 1.8
17 | 1.8
18 | true
19 |
20 |
21 |
22 | org.apache.maven.plugins
23 | maven-jar-plugin
24 | 2.4
25 |
26 |
27 |
28 | Main
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/cheerpj/cheerpjswing/src/main/java/Main.java:
--------------------------------------------------------------------------------
1 | import javax.swing.*;
2 | import java.awt.*;
3 | import java.util.function.Consumer;
4 |
5 | public class Main implements Runnable {
6 |
7 | @Override
8 | public void run() {
9 | JFrame frame = new JFrame( "CheerpJ Demo" );
10 |
11 | frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
12 | frame.setSize( 400, 80 );
13 | frame.add( new Counter() );
14 | frame.setVisible( true );
15 | }
16 |
17 | public static void main( String[] args ) {
18 | SwingUtilities.invokeLater( new Main() );
19 | }
20 | }
21 |
22 | class Counter extends JPanel {
23 | private int value;
24 |
25 | public Counter() {
26 | JButton up = new JButton( "Increment" );
27 | JButton down = new JButton( "Decrement" );
28 | JLabel out = new JLabel();
29 |
30 | Runnable update = () -> out.setText( "The current count is " + value );
31 | update.run();
32 |
33 | Consumer handler = ( increment ) -> {
34 | if ( increment ) {
35 | value++;
36 | } else {
37 | value--;
38 | }
39 | update.run();
40 | };
41 |
42 | up.addActionListener( event -> handler.accept( true ) );
43 | down.addActionListener( event -> handler.accept( false ) );
44 |
45 | JPanel buttonsPanel = new JPanel();
46 | buttonsPanel.add( up );
47 | buttonsPanel.add( down );
48 |
49 | JLabel title = new JLabel( "CheerpJ CounterApp (Swing)" );
50 |
51 | setLayout( new BorderLayout() );
52 | add( title, BorderLayout.PAGE_START );
53 | add( buttonsPanel, BorderLayout.PAGE_END );
54 | add( out, BorderLayout.CENTER );
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/cheerpj/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CheerpJ test
6 |
7 |
8 |
9 |
10 |
15 |
16 |
--------------------------------------------------------------------------------
/dart-counter/.gitignore:
--------------------------------------------------------------------------------
1 | # Files and directories created by pub
2 | .dart_tool/
3 | .packages
4 | # Remove the following pattern if you wish to check in your lock file
5 | pubspec.lock
6 |
7 | # Conventional directory for build outputs
8 | build/
9 |
10 | # Directory created by dartdoc
11 | doc/api/
12 |
--------------------------------------------------------------------------------
/dart-counter/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 1.0.0
2 |
3 | - Initial version, created by Stagehand
4 |
--------------------------------------------------------------------------------
/dart-counter/README.md:
--------------------------------------------------------------------------------
1 | An absolute bare-bones web app.
2 |
3 | Created from templates made available by Stagehand under a BSD-style
4 | [license](https://github.com/dart-lang/stagehand/blob/master/LICENSE).
5 |
--------------------------------------------------------------------------------
/dart-counter/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # Defines a default set of lint rules enforced for
2 | # projects at Google. For details and rationale,
3 | # see https://github.com/dart-lang/pedantic#enabled-lints.
4 | include: package:pedantic/analysis_options.yaml
5 |
6 | # For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
7 | # Uncomment to specify additional rules.
8 | # linter:
9 | # rules:
10 | # - camel_case_types
11 |
12 | analyzer:
13 | # exclude:
14 | # - path/to/excluded/files/**
15 |
--------------------------------------------------------------------------------
/dart-counter/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: dart_counter
2 | description: An absolute bare-bones web app.
3 | # version: 1.0.0
4 | #homepage: https://www.example.com
5 | #author: renato
6 |
7 | environment:
8 | sdk: '>=2.1.0 <3.0.0'
9 |
10 | #dependencies:
11 | # path: ^1.4.1
12 |
13 | dev_dependencies:
14 | build_runner: ^1.1.2
15 | build_web_compilers: ^1.0.0
16 | pedantic: ^1.0.0
17 |
--------------------------------------------------------------------------------
/dart-counter/web/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/renatoathaydes/jvm-alternatives-to-js/40337a4d0b3a79b3b2f0ad529440fc1f22ab6b0b/dart-counter/web/favicon.ico
--------------------------------------------------------------------------------
/dart-counter/web/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Dart CounterApp
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/dart-counter/web/main.dart:
--------------------------------------------------------------------------------
1 | import 'dart:html';
2 |
3 | void main() {
4 | querySelector('#output').append(Counter().build());
5 | }
6 |
7 | class Counter {
8 | int value = 0;
9 |
10 | Element build() {
11 | final out = DivElement();
12 |
13 | update() => out.text = "The current count is $value";
14 | update();
15 | handler(bool increment) {
16 | if (increment)
17 | value++;
18 | else
19 | value--;
20 | update();
21 | }
22 |
23 | final up = ButtonElement()
24 | ..text = 'Increment'
25 | ..onClick.listen((e) => handler(true));
26 | final down = ButtonElement()
27 | ..text = 'Decrement'
28 | ..onClick.listen((e) => handler(false));
29 |
30 | return DivElement()..append(out)..append(up)..append(down);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/dart-counter/web/styles.css:
--------------------------------------------------------------------------------
1 | @import url(https://fonts.googleapis.com/css?family=Roboto);
2 |
3 | html, body {
4 | width: 100%;
5 | height: 100%;
6 | margin: 0;
7 | padding: 0;
8 | font-family: 'Roboto', sans-serif;
9 | }
10 |
11 | #output {
12 | padding: 20px;
13 | text-align: center;
14 | }
15 |
--------------------------------------------------------------------------------
/gwt-app/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/gwt-app/.gitignore:
--------------------------------------------------------------------------------
1 | gwt-unitCache/
2 | war/gwtapp/
3 | war/WEB-INF/lib/
4 | war/WEB-INF/deploy/
5 |
6 |
--------------------------------------------------------------------------------
/gwt-app/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | GwtApp
4 | GwtApp project
5 |
6 |
7 |
8 | org.eclipse.jdt.core.javabuilder
9 |
10 |
11 |
12 |
13 | com.google.gdt.eclipse.core.webAppProjectValidator
14 |
15 |
16 |
17 |
18 | com.google.gwt.eclipse.core.gwtProjectValidator
19 |
20 |
21 |
22 |
23 |
24 | org.eclipse.jdt.core.javanature
25 | com.google.gwt.eclipse.core.gwtNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/gwt-app/GwtApp.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/gwt-app/README.txt:
--------------------------------------------------------------------------------
1 | --- Generated by GWT WebAppCreator ---
2 |
3 | Congratulations, you've successfully generated a starter project! What next?
4 |
5 | -- Option A: Import your project into Eclipse (recommended) --
6 |
7 | If you use Eclipse, you can simply import the generated project into Eclipse.
8 | We've tested against Eclipse 3.4 and 3.5. Later versions will likely also
9 | work, earlier versions may not.
10 |
11 | If the directory containing this file does not have a .classpath or .project
12 | file, generate them by running 'ant eclipse.generate'
13 |
14 | In Eclipse, go to the File menu and choose:
15 |
16 | File -> Import... -> Existing Projects into Workspace
17 |
18 | Browse to the directory containing this file,
19 | select "GwtApp".
20 |
21 | Be sure to uncheck "Copy projects into workspace" if it is checked.
22 |
23 | Click Finish.
24 |
25 | You can now browse the project in Eclipse.
26 |
27 | To launch your web app in GWT development mode, go to the Run menu and choose:
28 |
29 | Run -> Open Debug Dialog...
30 |
31 | Under Java Application, you should find a launch configuration
32 | named "GwtApp". Select and click "Debug".
33 |
34 | You can now use the built-in debugger to debug your web app in development mode.
35 |
36 | If you supplied the junit path when invoking webAppCreator, you should see
37 | launch configurations for running your tests in development and production
38 | mode.
39 |
40 | -- Option B: Build from the command line with Ant --
41 |
42 | If you prefer to work from the command line, you can use Ant to build your
43 | project. (http://ant.apache.org/) Ant uses the generated 'build.xml' file
44 | which describes exactly how to build your project. This file has been tested
45 | to work against Ant 1.7.1. The following assumes 'ant' is on your command
46 | line path.
47 |
48 | To run development mode, just type 'ant devmode'.
49 |
50 | To compile your project for deployment, just type 'ant'.
51 |
52 | To compile and also bundle into a .war file, type 'ant war'.
53 |
54 | If you supplied the junit path when invoking webAppCreator, you can type 'ant
55 | test' to run tests in development and production mode.
56 |
57 | For a full listing of other targets, type 'ant -p'.
58 |
59 | -- Option C: Using another IDE --
60 |
61 | GWT projects can be run in other IDEs as well, but will require some manual
62 | setup. If you go this route, be sure to:
63 |
64 | * Have your IDE build .class files into 'war/WEB-INF/classes'.
65 | * Add gwt-user.jar and gwt-dev.jar to your project build path.
66 | * When creating a launch configuration, add a classpath entry for your 'src'
67 | folder (this is somewhat unusual but GWT needs access to your source files).
68 |
69 | If you get stuck, try to mimic what the Ant 'build.xml' would do.
70 |
71 | -- Option D: Using Maven --
72 |
73 | If you have generated your project with the option '-maven', you have a 'pom.xml'
74 | file ready to use. Assuming you have Maven installed in your system, 'mvn' is
75 | in your path, and you have access to maven repositories, you should be able to run:
76 |
77 | mvn clean # delete temporary stuff
78 | mvn test # run all the tests (gwt and junit)
79 | mvn gwt:devmode # run development mode (needs "mvn package" to be run before)
80 | mvn package # generate a .war package ready to deploy
81 |
82 | For more information about other available goals, read Maven and gwt-maven-plugin
83 | documentation (http://maven.apache.org, https://tbroyer.github.io/gwt-maven-plugin/)
84 |
--------------------------------------------------------------------------------
/gwt-app/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
--------------------------------------------------------------------------------
/gwt-app/src/com/athaydes/GwtApp.gwt.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/gwt-app/src/com/athaydes/client/GwtApp.java:
--------------------------------------------------------------------------------
1 | package com.athaydes.client;
2 |
3 | import com.google.gwt.core.client.EntryPoint;
4 | import com.google.gwt.user.client.ui.*;
5 |
6 | import java.util.function.Consumer;
7 |
8 | public class GwtApp implements EntryPoint {
9 | public void onModuleLoad() {
10 | RootPanel.get( "content" ).add( new Counter() );
11 | }
12 | }
13 |
14 | class Counter extends Composite {
15 |
16 | private int value;
17 |
18 | Counter() {
19 | HorizontalPanel buttonsPanel = new HorizontalPanel();
20 | buttonsPanel.setSpacing( 10 );
21 |
22 | Button up = new Button( "Increment" );
23 | Button down = new Button( "Decrement" );
24 | Label out = new Label();
25 |
26 | Runnable update = () -> out.setText( "The current count is " + value );
27 | update.run();
28 |
29 | Consumer handler = ( increment ) -> {
30 | if ( increment ) {
31 | value++;
32 | } else {
33 | value--;
34 | }
35 | update.run();
36 | };
37 |
38 | up.addClickHandler( clickEvent -> handler.accept( true ) );
39 | down.addClickHandler( clickEvent -> handler.accept( false ) );
40 |
41 | buttonsPanel.add( up );
42 | buttonsPanel.add( down );
43 |
44 | VerticalPanel root = new VerticalPanel();
45 | root.setSpacing( 20 );
46 |
47 | root.add( out );
48 | root.add( buttonsPanel );
49 |
50 | initWidget( root );
51 | }
52 |
53 | }
--------------------------------------------------------------------------------
/gwt-app/war/GwtApp.css:
--------------------------------------------------------------------------------
1 | /** Add css rules here for your application. */
2 |
3 |
4 | /** Example rules used by the template application (remove for your app) */
5 | h1 {
6 | font-size: 2em;
7 | font-weight: bold;
8 | color: #777777;
9 | margin: 40px 0px 70px;
10 | text-align: center;
11 | }
12 |
13 | .sendButton {
14 | display: block;
15 | font-size: 16pt;
16 | }
17 |
18 | /** Most GWT widgets already have a style name defined */
19 | .gwt-DialogBox {
20 | width: 400px;
21 | }
22 |
23 | .dialogVPanel {
24 | margin: 5px;
25 | }
26 |
27 | .serverResponseLabelError {
28 | color: red;
29 | }
30 |
31 | /** Set ids using widget.getElement().setId("idOfElement") */
32 | #closeButton {
33 | margin: 15px 6px 6px;
34 | }
35 |
--------------------------------------------------------------------------------
/gwt-app/war/GwtApp.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Web Application Starter Project
7 |
8 |
9 |
10 |
16 |
GWT CounterApp
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/gwt-app/war/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | GwtApp.html
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/gwt-app/war/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/renatoathaydes/jvm-alternatives-to-js/40337a4d0b3a79b3b2f0ad529440fc1f22ab6b0b/gwt-app/war/favicon.ico
--------------------------------------------------------------------------------
/jsweet/..gitignore.swp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/renatoathaydes/jvm-alternatives-to-js/40337a4d0b3a79b3b2f0ad529440fc1f22ab6b0b/jsweet/..gitignore.swp
--------------------------------------------------------------------------------
/jsweet/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 | target/
3 | .generated
4 | .ts
5 | .jsweet
6 | .project
7 | .settings
8 | .classpath
9 |
--------------------------------------------------------------------------------
/jsweet/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/jsweet/README.md:
--------------------------------------------------------------------------------
1 | # JSweet quick start
2 |
3 | A simple project to get started with JSweet. This project just contains a main method that shows 'Hello world' messages in two different ways. The program uses the [J4TS](https://github.com/cincheo/j4ts) candy to access `java.util` API, and the jQuery candy. Programmers can use it to set up a new JSweet project and try out some basic features.
4 |
5 | ## Usage
6 |
7 | ```
8 | > git clone https://github.com/cincheo/jsweet-quickstart.git
9 | > cd jsweet-quickstart
10 | > mvn generate-sources
11 | > firefox webapp/index.html
12 | ```
13 |
14 | You can also watch your JSweet (.java) source files for modifications using
15 | ```
16 | mvn clean jsweet:watch
17 | ```
18 | It will transpile automatically when you save a source file.
19 | Be sure that there are not transpilation error in your console, though.
20 |
21 | ## Modify
22 |
23 | At any time, you can modify the Java files (or add new files) and run ``mvn generate-sources`` to generate the corresponding JavaScript files. You can then use them in the ``index.html`` file (``
17 |