Skip to content

Commit 2273c2f

Browse files
authored
Merge pull request #36 from BobHanson/master
Udo's .j2s fix
2 parents 50b0e6c + 628c301 commit 2273c2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1135
-25
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
tests/net.sf.j2s.test.junit/bin/*
22
*/*/bin
33
sources/net.sf.j2s.lib/j2slib
4-
dist/*
4+
/.project
5+
docs/_site
6+
.jekyll-metadata
7+

LICENSE.txt

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
Java2Script/SwingJS is free software: you can redistribute it and/or modify
2+
it under the terms of the GNU Lesser General Public License as published by the
3+
Free Software Foundation,  version 3 of the License.
4+
5+
Java2Script/SwingJS was originally licensed under an Eclipse Public License 1.0.
6+
Over time code with other licenses was added, including code from OpenJDK under
7+
GNU LGPL. Therefore the original author of Java2Script/SwingJS and contributors to the
8+
software have agreed to modify the license to the GNU LGPL.
9+
10+
Java2Script/SwingJS is distributed in the hope that it will be useful, but
11+
WITHOUT ANY WARRANTY EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE OR USE.  
13+
14+
See the GNU Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public License along
17+
with Java2Script/SwingJS.  If not, see http://www.gnu.org/licenses/lgpl.html
18+
19+
===============================================================================
20+
21+
GNU LESSER GENERAL PUBLIC LICENSE
22+
Version 3, 29 June 2007
23+
24+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
25+
Everyone is permitted to copy and distribute verbatim copies
26+
of this license document, but changing it is not allowed.
27+
28+
29+
This version of the GNU Lesser General Public License incorporates
30+
the terms and conditions of version 3 of the GNU General Public
31+
License, supplemented by the additional permissions listed below.
32+
33+
0. Additional Definitions.
34+
35+
As used herein, "this License" refers to version 3 of the GNU Lesser
36+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
37+
General Public License.
38+
39+
"The Library" refers to a covered work governed by this License,
40+
other than an Application or a Combined Work as defined below.
41+
42+
An "Application" is any work that makes use of an interface provided
43+
by the Library, but which is not otherwise based on the Library.
44+
Defining a subclass of a class defined by the Library is deemed a mode
45+
of using an interface provided by the Library.
46+
47+
A "Combined Work" is a work produced by combining or linking an
48+
Application with the Library. The particular version of the Library
49+
with which the Combined Work was made is also called the "Linked
50+
Version".
51+
52+
The "Minimal Corresponding Source" for a Combined Work means the
53+
Corresponding Source for the Combined Work, excluding any source code
54+
for portions of the Combined Work that, considered in isolation, are
55+
based on the Application, and not on the Linked Version.
56+
57+
The "Corresponding Application Code" for a Combined Work means the
58+
object code and/or source code for the Application, including any data
59+
and utility programs needed for reproducing the Combined Work from the
60+
Application, but excluding the System Libraries of the Combined Work.
61+
62+
1. Exception to Section 3 of the GNU GPL.
63+
64+
You may convey a covered work under sections 3 and 4 of this License
65+
without being bound by section 3 of the GNU GPL.
66+
67+
2. Conveying Modified Versions.
68+
69+
If you modify a copy of the Library, and, in your modifications, a
70+
facility refers to a function or data to be supplied by an Application
71+
that uses the facility (other than as an argument passed when the
72+
facility is invoked), then you may convey a copy of the modified
73+
version:
74+
75+
a) under this License, provided that you make a good faith effort to
76+
ensure that, in the event an Application does not supply the
77+
function or data, the facility still operates, and performs
78+
whatever part of its purpose remains meaningful, or
79+
80+
b) under the GNU GPL, with none of the additional permissions of
81+
this License applicable to that copy.
82+
83+
3. Object Code Incorporating Material from Library Header Files.
84+
85+
The object code form of an Application may incorporate material from
86+
a header file that is part of the Library. You may convey such object
87+
code under terms of your choice, provided that, if the incorporated
88+
material is not limited to numerical parameters, data structure
89+
layouts and accessors, or small macros, inline functions and templates
90+
(ten or fewer lines in length), you do both of the following:
91+
92+
a) Give prominent notice with each copy of the object code that the
93+
Library is used in it and that the Library and its use are
94+
covered by this License.
95+
96+
b) Accompany the object code with a copy of the GNU GPL and this license
97+
document.
98+
99+
4. Combined Works.
100+
101+
You may convey a Combined Work under terms of your choice that,
102+
taken together, effectively do not restrict modification of the
103+
portions of the Library contained in the Combined Work and reverse
104+
engineering for debugging such modifications, if you also do each of
105+
the following:
106+
107+
a) Give prominent notice with each copy of the Combined Work that
108+
the Library is used in it and that the Library and its use are
109+
covered by this License.
110+
111+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
112+
document.
113+
114+
c) For a Combined Work that displays copyright notices during
115+
execution, include the copyright notice for the Library among
116+
these notices, as well as a reference directing the user to the
117+
copies of the GNU GPL and this license document.
118+
119+
d) Do one of the following:
120+
121+
0) Convey the Minimal Corresponding Source under the terms of this
122+
License, and the Corresponding Application Code in a form
123+
suitable for, and under terms that permit, the user to
124+
recombine or relink the Application with a modified version of
125+
the Linked Version to produce a modified Combined Work, in the
126+
manner specified by section 6 of the GNU GPL for conveying
127+
Corresponding Source.
128+
129+
1) Use a suitable shared library mechanism for linking with the
130+
Library. A suitable mechanism is one that (a) uses at run time
131+
a copy of the Library already present on the user's computer
132+
system, and (b) will operate properly with a modified version
133+
of the Library that is interface-compatible with the Linked
134+
Version.
135+
136+
e) Provide Installation Information, but only if you would otherwise
137+
be required to provide such information under section 6 of the
138+
GNU GPL, and only to the extent that such information is
139+
necessary to install and execute a modified version of the
140+
Combined Work produced by recombining or relinking the
141+
Application with a modified version of the Linked Version. (If
142+
you use option 4d0, the Installation Information must accompany
143+
the Minimal Corresponding Source and Corresponding Application
144+
Code. If you use option 4d1, you must provide the Installation
145+
Information in the manner specified by section 6 of the GNU GPL
146+
for conveying Corresponding Source.)
147+
148+
5. Combined Libraries.
149+
150+
You may place library facilities that are a work based on the
151+
Library side by side in a single library together with other library
152+
facilities that are not Applications and are not covered by this
153+
License, and convey such a combined library under terms of your
154+
choice, if you do both of the following:
155+
156+
a) Accompany the combined library with a copy of the same work based
157+
on the Library, uncombined with any other library facilities,
158+
conveyed under the terms of this License.
159+
160+
b) Give prominent notice with the combined library that part of it
161+
is a work based on the Library, and explaining where to find the
162+
accompanying uncombined form of the same work.
163+
164+
6. Revised Versions of the GNU Lesser General Public License.
165+
166+
The Free Software Foundation may publish revised and/or new versions
167+
of the GNU Lesser General Public License from time to time. Such new
168+
versions will be similar in spirit to the present version, but may
169+
differ in detail to address new problems or concerns.
170+
171+
Each version is given a distinguishing version number. If the
172+
Library as you received it specifies that a certain numbered version
173+
of the GNU Lesser General Public License "or any later version"
174+
applies to it, you have the option of following the terms and
175+
conditions either of that published version or of any later version
176+
published by the Free Software Foundation. If the Library as you
177+
received it does not specify a version number of the GNU Lesser
178+
General Public License, you may choose any version of the GNU Lesser
179+
General Public License ever published by the Free Software Foundation.
180+
181+
If the Library as you received it specifies that a proxy can decide
182+
whether future versions of the GNU Lesser General Public License shall
183+
apply, that proxy's public statement of acceptance of any version is
184+
permanent authorization for you to choose that version for the
185+
Library.

README-developers.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Notes for developers of java2script/SwingJS
2+
3+
These notes are for developers of SwingJS, not for users of SwingJS.
4+
5+
```
6+
cd workspace (where workspace is your Eclipse Neon Workspace)
7+
git clone https://github.com/BobHanson/java2script.git
8+
git checkout swingjs
9+
```
10+
11+
Then, open Eclipse, open Navigator, and hit Refresh. java2script will show up as a blank generic trunk without a name (i.e. 'trunk[]')
12+
13+
![Eclipse Refresh](https://68.media.tumblr.com/47add4de1bc35f07f0e709fd6634289d/tumblr_or8mhqHsje1s5a4bko3_1280.png)
14+
15+
![Eclipse trunk](https://68.media.tumblr.com/866cc531b6b9d1c3dca8071732a66a26/tumblr_or8mihapDW1s5a4bko1_540.png)
16+
17+
Or, do the equivalent tasks on Eclipse's graphical git tool.
18+
19+
Go to net.sf.j2s.core directory, Clean Project, then export as a Deployable plug-ins and fragments.
20+
21+
![Eclipse Deployable](https://68.media.tumblr.com/c5714cadb166c7a887fbd00110e19afc/tumblr_or8mhqHsje1s5a4bko1_1280.png)
22+
23+
![Eclipse Optionsj](https://68.media.tumblr.com/0a7d77765983c11ca59b4739307359ee/tumblr_or8mhqHsje1s5a4bko2_1280.png)
24+
25+
Core is the only thing that was affected. Hence, everything else can be built the same exact way it was built before (assuming you were using the HEAD of the master branch of j2s).

README.md

Lines changed: 69 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,78 @@
1-
# Quick Build Directions
1+
# Note
22

3-
```
4-
cd workspace (where workspace is your Eclipse Neon Workspace)
5-
git clone https://github.com/BobHanson/java2script.git
6-
git checkout swingjs
7-
```
83

9-
Then, open Eclipse, open Navigator, and hit Refresh. java2script will show up as a blank generic trunk without a name (i.e. 'trunk[]')
4+
These notes are for Java developers who want to convert their Java applets or Java applications to
5+
JavaScript, allowing continued one-source development of both Java and JavaScript.
106

11-
![Eclipse Refresh](https://68.media.tumblr.com/47add4de1bc35f07f0e709fd6634289d/tumblr_or8mhqHsje1s5a4bko3_1280.png)
7+
Developers of java2script/SwingJS itself should read README-developers.md
128

13-
![Eclipse trunk](https://68.media.tumblr.com/866cc531b6b9d1c3dca8071732a66a26/tumblr_or8mihapDW1s5a4bko1_540.png)
9+
Bob Hanson (hansonr@stolaf.edu)
1410

15-
Or, do the equivalent tasks on Eclipse's graphical git tool.
1611

17-
Go to net.sf.j2s.core directory, Clean Project, then export as a Deployable plug-ins and fragments.
12+
# About java2script/SwingJS
1813

19-
![Eclipse Deployable](https://68.media.tumblr.com/c5714cadb166c7a887fbd00110e19afc/tumblr_or8mhqHsje1s5a4bko1_1280.png)
14+
java2script/SwingJS is not a one-time "port" to JavaScript. It is a system that allows real-time Java-to-JavaScript conversion
15+
within Eclipse, with immediate JavaScript testing and debugging in a browser based on code development
16+
in Java. Using the java2script/SwingJS Eclipse plug-in, both Java .class files and their equivalent .js files are created simultaneously.
2017

21-
![Eclipse Optionsj](https://68.media.tumblr.com/0a7d77765983c11ca59b4739307359ee/tumblr_or8mhqHsje1s5a4bko2_1280.png)
2218

23-
Core is the only thing that was affected. Hence, everything else can be built the same exact way it was built before (assuming you were using the HEAD of the master branch of j2s).
19+
java2script/SwingJS includes an Eclipse plug-in (technically a "drop-in"), net.sf.j2s.core.zip
20+
(see https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.core/dist/dropins),
21+
along with a JavaScript version of the Java Virtual Machine (SwingJS, https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.java.core/SwingJS-site.zip)
22+
to allow the rapid and
23+
automated production of browser-ready JavaScript versions of Java applications and applets.
24+
25+
26+
# QuickStart
27+
28+
See https://github.com/BobHanson/java2script/tree/master/dist and the README file in that directory.
29+
30+
# History - 2017-
31+
32+
33+
https://github.com/BobHanson/java2script (development master)
34+
35+
Current development "Version 3 development master" involving a completely rewritten transpiler (2017) that nearly perfectly emulates the Java Virtual Machine, including fully qualified methods, compile-time method binding, generic methods and classes, Java reflection for efficient modular just-in-time class loading, Java Swing components, modal and nonmodel dialogs, audio, jpdf, the AWT event thread, and many other added packages. Java applications and applets can both be run in JavaScript in a browser.
36+
37+
Version 3 also implements real-time creation of HTML test files for immediate JavaScript testing of any changes made to the Java code. Basically, when the source file is saveed in Eclipse, the JavaScript updates automatically, and a reload of the page in the browser shows the changes directly. This makes for very easy side-by-side Java and JavaScript debugging.
38+
39+
Unlike Version 2, Version 3 requires minimal reworking of Java classes - primarily just for performance and threading* reasons, maximizing JavaScript performance without compromising any Java performance and making Java-to-JavaScript conversion almost trivial. (Of course, we are still finding occasional bugs in the transpiler and run-time "JavaScript-JVM.")
40+
41+
*Note that java2script/SwingJS cannot not support Thread.wait(), Thread.notify(), or Thread.sleep(). Nonetheless, in all cases we have found simple state-based alternatives that essentially reproduce this behavior in JavaScript using javax.Swing.Timer. These methods work equally well in Java and JavaScript, requiring just a bit of redesign of Java methods.
42+
43+
Examples include:
44+
45+
Physlets (https://github.com/BobHanson/Physlets-SwingJS) conversion to JavaScript by Wolfgang Christian (wochristian@davidson.edu) and Bob Hanson (in progress).
46+
47+
Jmol-SwingJS https://github.com/BobHanson/Jmol-SwingJS (code only)
48+
49+
Varna https://github.com/BobHanson/VARNA and https://chemapps.stolaf.edu/swingjs/varna
50+
51+
# History - 2010-2016
52+
53+
https://github.com/java2script/java2script (stable master)
54+
55+
Ported from SourceForge by Zhou Renjian, developed further by Zhou Renjian and Udo Borkowski (primariy) as "Version 2.0".
56+
57+
Extensively used by Bob Hanson in 2012-2016 for the conversion of Jmol/java to JSmol/javascript (http://jmol.sourceforge.net/), leading to extensive distribution and widespread use on the web. As of 3/2018, still the
58+
only known widely-available java2sript application.
59+
60+
Developed further in 2016 by zhou Renjian, Udo Borkowski, Bob Hanson, Andrew Raduege, Nadia El Mouldi, and Paul Falstad (http://www.falstad.com) for the first round of post-JSmol application of java2script, adding javax.swing classes and
61+
dubbed "SwingJS". Used by Bob Hanson during 11/2016 for conversion of the PhET gas applications applets.
62+
63+
Version 2 allowed extensive development of JavaScript versions of Java applets, including JSmol, Falstad applets, and PhET applets.
64+
However, this version did not produce "fully qualified" method signatures, resulting in error-prone and performance-reducing run-time binding of methods. Java class loading procedures were not consistent with the seqence of events used by the Java class loader, and parameter and array typing was minimal. Thus, while functional, Version 2 was not fully generalizable and required extensive reworking of Java code to be "java2script compliant."
65+
66+
Synchronized with https://github.com/BobHanson/java2script as the stable master version in 2018.
67+
68+
Examples can be found at https://chemapps.stolaf.edu/swingjs/phet/site/swingjs/examples
69+
and https://chemapps.stolaf.edu/jmol/jsmol
70+
71+
# History - 2005-2010
72+
73+
https://sourceforge.net/projects/j2s (last updated 6/2010)
74+
75+
Initially developed by Zhou Renjian (aka "Josson Smith", zhourenjian@gmail.com, 2005-2017),
76+
Soheil Hassas Yeganeh (soheil.h.y@gmail.com, 2006), Sal Ferro (svferro@gmail.com, 2006), Sebastian Gurin (sgurin@softpoint.org, 2008),
77+
and others. The project was a "proof-in-concept" that saw limited actual application.
78+

0 commit comments

Comments
 (0)