Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
5735311
Merge pull request #20 from BobHanson/master
BobHanson Feb 17, 2018
0c6f023
Merge pull request #23 from BobHanson/master
BobHanson Feb 17, 2018
bac9709
Merge pull request #24 from BobHanson/yadav1
BobHanson Mar 8, 2018
5d707fc
Merge pull request #10 from BobHanson/yadav1
BobHanson Mar 15, 2018
91fda97
Merge pull request #11 from BobHanson/yadav1
BobHanson Mar 15, 2018
befdc7b
moving old dist files out
BobHanson Mar 15, 2018
c437226
saving old releases
BobHanson Mar 15, 2018
3dbcec3
ignore top-level .project file
BobHanson Mar 15, 2018
fe53fac
new readme
BobHanson Mar 15, 2018
e428355
Merge pull request #25 from BobHanson/yadav1
BobHanson Mar 17, 2018
e8f90f1
Merge pull request #12 from BobHanson/yadav1
BobHanson Mar 17, 2018
d78e8b5
Merge pull request #26 from BobHanson/yadav1
BobHanson Mar 17, 2018
20dbc66
Merge pull request #13 from BobHanson/yadav1
BobHanson Mar 18, 2018
ee09782
Merge pull request #27 from BobHanson/master
BobHanson Mar 18, 2018
497aba4
readme upgrade
BobHanson Mar 18, 2018
c509ac1
Merge branch 'master' of https://github.com/BobHanson/java2script.git
BobHanson Mar 18, 2018
52d74ae
readme
BobHanson Mar 18, 2018
e95adf6
readme
BobHanson Mar 18, 2018
a990924
readme
BobHanson Mar 18, 2018
bf00a57
readme
BobHanson Mar 18, 2018
53d1bde
readme
BobHanson Mar 18, 2018
84e3056
Merge pull request #28 from BobHanson/master
BobHanson Mar 18, 2018
5b63a2b
readme
BobHanson Mar 18, 2018
73e168b
Merge pull request #29 from BobHanson/master
BobHanson Mar 18, 2018
7fa97a6
readme
BobHanson Mar 18, 2018
c42003d
Merge pull request #30 from BobHanson/master
BobHanson Mar 18, 2018
8eef034
readme
BobHanson Mar 18, 2018
369067e
Merge pull request #31 from BobHanson/master
BobHanson Mar 18, 2018
311eede
readme
BobHanson Mar 18, 2018
a8f853c
readme
BobHanson Mar 18, 2018
81020d0
readme
BobHanson Mar 18, 2018
8b9ac4c
Merge pull request #32 from BobHanson/master
BobHanson Mar 18, 2018
0303e1b
readme
BobHanson Mar 18, 2018
4dfecf6
Merge pull request #33 from BobHanson/master
BobHanson Mar 18, 2018
6a0a871
readme
BobHanson Mar 18, 2018
4154ab3
readme
BobHanson Mar 18, 2018
7e6c4c6
readme
BobHanson Mar 18, 2018
2c26fcc
Merge pull request #34 from BobHanson/master
BobHanson Mar 18, 2018
66cf46d
Merge pull request #14 from BobHanson/yadav1
BobHanson Mar 28, 2018
37a6916
Merge pull request #35 from BobHanson/master
BobHanson Mar 28, 2018
138f600
Merge pull request #15 from java2script/master
BobHanson Mar 28, 2018
a9e720b
Merge pull request #16 from BobHanson/yadav1
BobHanson Mar 28, 2018
8ec6405
adds reference to net.sf.j2s.core/dist/dropins
BobHanson Mar 28, 2018
6bff7d7
Merge pull request #17 from BobHanson/yadav1
BobHanson Apr 3, 2018
6cc172f
Merge pull request #36 from BobHanson/master
BobHanson Apr 3, 2018
5fd0560
add webpage (for Github Pages)
abego Apr 5, 2018
d653e13
Merge pull request #37 from abego/master
abego Apr 6, 2018
d626721
Bug: webpage: 'Java2Script' link in header is broken
abego Apr 6, 2018
bff2eef
Merge pull request #38 from abego/master
abego Apr 6, 2018
1846220
Merge pull request #40 from BobHanson/yadav1
BobHanson May 15, 2018
3e21a5b
Merge pull request #18 from BobHanson/yadav1
BobHanson May 15, 2018
bce9e06
Merge pull request #19 from BobHanson/yadav1
BobHanson May 15, 2018
930aae3
Merge branch 'master' into master
BobHanson May 15, 2018
fca9228
Merge pull request #41 from BobHanson/master
BobHanson May 15, 2018
a774ed0
Merge pull request #20 from BobHanson/yadav1
BobHanson May 21, 2018
fbd83d8
Merge pull request #42 from BobHanson/master
BobHanson May 21, 2018
9987946
GLPL licence
BobHanson May 23, 2018
db95d75
Merge branch 'master' of https://github.com/BobHanson/java2script.git
BobHanson May 23, 2018
dcc4395
GLPL license
BobHanson May 23, 2018
a653b97
Merge pull request #43 from BobHanson/master
BobHanson May 23, 2018
6f70e23
Merge pull request #21 from BobHanson/yadav1
BobHanson May 24, 2018
11c7752
Merge pull request #44 from BobHanson/master
BobHanson May 24, 2018
f11dbad
Merge pull request #45 from BobHanson/yadav1
BobHanson May 24, 2018
2e806cd
Merge pull request #22 from BobHanson/yadav1
BobHanson May 24, 2018
a33c72e
Merge pull request #46 from BobHanson/master
BobHanson May 24, 2018
0222f45
Merge pull request #23 from BobHanson/yadav1
BobHanson May 29, 2018
110663d
Merge pull request #47 from BobHanson/yadav1
BobHanson May 29, 2018
b73ee6f
moving SwingJS-site.zip to core.java/dist
BobHanson Jun 19, 2018
fef1a1a
Merge branch 'master' of https://github.com/BobHanson/java2script.git
BobHanson Jun 19, 2018
483ddb6
Merge pull request #24 from BobHanson/yadav1
BobHanson Jun 20, 2018
cdb45c4
Merge pull request #25 from BobHanson/yadav1
BobHanson Jun 20, 2018
dafc2ef
Merge pull request #48 from BobHanson/yadav1
BobHanson Jun 24, 2018
181fcdd
Merge pull request #26 from BobHanson/yadav1
BobHanson Jun 24, 2018
40bae9d
Merge pull request #49 from BobHanson/yadav1
BobHanson Jun 24, 2018
fd48cfb
Merge pull request #27 from BobHanson/yadav1
BobHanson Jun 24, 2018
f304325
Merge pull request #28 from BobHanson/yadav1
BobHanson Jun 25, 2018
a811459
Merge pull request #50 from BobHanson/yadav1
BobHanson Jun 25, 2018
1b92c88
Merge pull request #30 from BobHanson/yadav1
BobHanson Jul 6, 2018
45d44e6
Merge pull request #51 from BobHanson/yadav1
BobHanson Jul 6, 2018
edecfc2
Merge pull request #32 from BobHanson/yadav1
BobHanson Jul 14, 2018
47f91d3
Merge pull request #33 from BobHanson/yadav1
BobHanson Jul 14, 2018
af32092
Merge pull request #34 from BobHanson/yadav1
BobHanson Jul 20, 2018
4c08840
Merge pull request #52 from BobHanson/yadav1
BobHanson Jul 20, 2018
7622dc6
Bug: J2S compiler not activated on Linux/macOS (Wrong ".J2S" file name)
abego Jul 22, 2018
f7f45d6
Merge pull request #54 from abego/wrong_dotj2s_literal
BobHanson Jul 22, 2018
788ae01
Merge pull request #55 from BobHanson/yadav1
BobHanson Jul 22, 2018
e88dcf9
Merge branch 'master' into master
BobHanson Jul 22, 2018
628c301
Merge pull request #35 from java2script/master
BobHanson Jul 22, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
tests/net.sf.j2s.test.junit/bin/*
*/*/bin
sources/net.sf.j2s.lib/j2slib
dist/*
/.project
docs/_site
.jekyll-metadata

185 changes: 185 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
Java2Script/SwingJS is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation,  version 3 of the License.

Java2Script/SwingJS was originally licensed under an Eclipse Public License 1.0.
Over time code with other licenses was added, including code from OpenJDK under
GNU LGPL. Therefore the original author of Java2Script/SwingJS and contributors to the
software have agreed to modify the license to the GNU LGPL.

Java2Script/SwingJS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE OR USE.  

See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with Java2Script/SwingJS.  If not, see http://www.gnu.org/licenses/lgpl.html

===============================================================================

GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.


This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.

0. Additional Definitions.

As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.

"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.

An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.

A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".

The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.

The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.

1. Exception to Section 3 of the GNU GPL.

You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.

2. Conveying Modified Versions.

If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:

a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or

b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.

3. Object Code Incorporating Material from Library Header Files.

The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:

a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the object code with a copy of the GNU GPL and this license
document.

4. Combined Works.

You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:

a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.

c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.

d) Do one of the following:

0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.

1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.

e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)

5. Combined Libraries.

You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:

a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.

b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.

6. Revised Versions of the GNU Lesser General Public License.

The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.

If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
25 changes: 25 additions & 0 deletions README-developers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Notes for developers of java2script/SwingJS

These notes are for developers of SwingJS, not for users of SwingJS.

```
cd workspace (where workspace is your Eclipse Neon Workspace)
git clone https://github.com/BobHanson/java2script.git
git checkout swingjs
```

Then, open Eclipse, open Navigator, and hit Refresh. java2script will show up as a blank generic trunk without a name (i.e. 'trunk[]')

![Eclipse Refresh](https://68.media.tumblr.com/47add4de1bc35f07f0e709fd6634289d/tumblr_or8mhqHsje1s5a4bko3_1280.png)

![Eclipse trunk](https://68.media.tumblr.com/866cc531b6b9d1c3dca8071732a66a26/tumblr_or8mihapDW1s5a4bko1_540.png)

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

Go to net.sf.j2s.core directory, Clean Project, then export as a Deployable plug-ins and fragments.

![Eclipse Deployable](https://68.media.tumblr.com/c5714cadb166c7a887fbd00110e19afc/tumblr_or8mhqHsje1s5a4bko1_1280.png)

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

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).
83 changes: 69 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,78 @@
# Quick Build Directions
# Note

```
cd workspace (where workspace is your Eclipse Neon Workspace)
git clone https://github.com/BobHanson/java2script.git
git checkout swingjs
```

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

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

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

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

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

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

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

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).
java2script/SwingJS includes an Eclipse plug-in (technically a "drop-in"), net.sf.j2s.core.zip
(see https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.core/dist/dropins),
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)
to allow the rapid and
automated production of browser-ready JavaScript versions of Java applications and applets.


# QuickStart

See https://github.com/BobHanson/java2script/tree/master/dist and the README file in that directory.

# History - 2017-


https://github.com/BobHanson/java2script (development master)

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.

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.

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.")

*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.

Examples include:

Physlets (https://github.com/BobHanson/Physlets-SwingJS) conversion to JavaScript by Wolfgang Christian (wochristian@davidson.edu) and Bob Hanson (in progress).

Jmol-SwingJS https://github.com/BobHanson/Jmol-SwingJS (code only)

Varna https://github.com/BobHanson/VARNA and https://chemapps.stolaf.edu/swingjs/varna

# History - 2010-2016

https://github.com/java2script/java2script (stable master)

Ported from SourceForge by Zhou Renjian, developed further by Zhou Renjian and Udo Borkowski (primariy) as "Version 2.0".

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
only known widely-available java2sript application.

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
dubbed "SwingJS". Used by Bob Hanson during 11/2016 for conversion of the PhET gas applications applets.

Version 2 allowed extensive development of JavaScript versions of Java applets, including JSmol, Falstad applets, and PhET applets.
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."

Synchronized with https://github.com/BobHanson/java2script as the stable master version in 2018.

Examples can be found at https://chemapps.stolaf.edu/swingjs/phet/site/swingjs/examples
and https://chemapps.stolaf.edu/jmol/jsmol

# History - 2005-2010

https://sourceforge.net/projects/j2s (last updated 6/2010)

Initially developed by Zhou Renjian (aka "Josson Smith", zhourenjian@gmail.com, 2005-2017),
Soheil Hassas Yeganeh (soheil.h.y@gmail.com, 2006), Sal Ferro (svferro@gmail.com, 2006), Sebastian Gurin (sgurin@softpoint.org, 2008),
and others. The project was a "proof-in-concept" that saw limited actual application.

Loading