@@ -2,7 +2,32 @@ SwingJS distribution
22
33https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.core/dist/dropins/README.txt
44
5- 7/15/2018 Bob Hanson hansonr@stolaf.edu
5+ 7/20/2018 Bob Hanson hansonr@stolaf.edu
6+
7+ The base Java version is Java 6. However, many of the functionalities of Java 7 and Java 8 are included.
8+ This includes
9+
10+ the "::" operator
11+ lambda expressions
12+ java.util.function.*
13+ java.util.stream.*
14+ default methods in interfaces
15+
16+ All projects compiled under 3.1.1 need to be recompiled using the Java2Script 3.2.1 transpiler, as
17+ described below. Note that if you use /** @j2sNative */ calls to interface methods that are singlets,
18+ you no longer need to add qualifications (such as $O) to them. It should be no problem to leave them
19+ qualified, though, as the transpiler creates qualified and unqualified aliases.
20+
21+ There are situations where this use of unqualified method names can run into problems. For example, in
22+ java.util.stream.ReferencePipeline, there are three different declarations of the functional interface
23+ method "accept". They were just for erro reporting and have been removed.
24+ My guess that this is a rarity, but I am not sure.
25+
26+
27+ SwingJS has been successfully tested in Eclipse version Neon-Photon on Mac and Windows platforms.
28+ (No reason to believe it would not also work for Linux; just haven't tried that recently.)
29+ Java 8 is the target Java version for transpilation. Please report any missing classes or strange
30+ errors.
631
732net.sf.j2s.core_3.2.1.jar replaces net.sf.j2s.core_3.1.1.jar
833
@@ -11,7 +36,7 @@ Most importantly, the requirement that the .project file be changed to
1136indicate a customized Java builder is dropped in version 3.2.1, which just uses
1237the standard Eclipse java builder, org.eclipse.jdt.core.javabuilder.
1338
14- Thus , to get started, all you need are:
39+ For v. 3.2.1 , to get started with SwingJS , all you need are:
1540
16411) the latest transpiler from
1742
@@ -31,8 +56,6 @@ or your project will no longer compile.
3156
3257Comments below have been adjusted for these differences.
3358
34- SwingJS has been successfully tested in Eclipse version Neon-Photon on Mac and Windows platforms.
35- (No reason to believe it would not also work for Linux; just haven't tried that recently.)
3659
3760INSTALLATION INSTRUCTIONS
3861
@@ -77,6 +100,10 @@ On Mac systems, the Eclipse directory is generally
771002. Restart Eclipse and check for the presence of the plug-in at
78101 help...about Eclipse...installation details...Plug-ins...(wait several seconds for tabulation)
79102
103+ Search for "j2s" to find j2s.sourceforge.net Java2Script Core
104+
105+ If that is not there, you don't have net.sf.j2s.core.jar in the proper directory.
106+
80107 Note relating to updating to 3.2.1 from 3.1.1 version of Java2Script:
81108
82109 If the version on this readout does not match the version that is
@@ -88,10 +115,6 @@ On Mac systems, the Eclipse directory is generally
88115 Eclipse once with the -clean flag.
89116
90117
91- search for "j2s" to find j2s.sourceforge.net Java2Script Core
92-
93- If that is not there, you don't have net.sf.j2s.core.jar in the proper directory.
94-
95118
96119----------------------------------
97120Creating a new J2S/SwingJS project
@@ -101,7 +124,7 @@ Create an Eclipse Java project for your work, if you have not done so already.
101124If your source code is not all already in src/, navigate to the project...properties...
102125Java Build Path...source and add all the source directories you need.
103126
104- Note that your project must not include any Jar file based dependencies.
127+ Note that your project must not include any Jar file- based dependencies.
105128All source code must be available. (Source code from decompiling .class files will work.)
106129
107130
@@ -124,36 +147,32 @@ Simply download and unzip that file into your project, creating a top-level site
124147Enabling the Java2Script/SwingJS transpiler
125148-------------------------------------------
126149
127- 1. Create in your Eclipse project the file:
150+ 1. Create in your Eclipse project the empty file:
128151
129152.j2s
130153
131- containing simply:
154+ The next time you build the project, the transpiler will see that and
155+ add to it:
132156
133157j2s.compiler.status=enable
158+ j2s.site.directory=site
134159
135- 2. Edit the .project file to indicate that the j2s transpiler is to be used
136- rather than the standard Java compiler by changing the buildSpec buildCommand from
137-
138- org.eclipse.jdt.core.javabuilder
139-
140- to
141-
142- net.sf.j2s.core.java2scriptbuilder
143-
160+ along with several other commented-out options. If you want, you can
161+ add these two yourself before you run the transpiler.
144162
145163--------------------
146164Building the project
147165--------------------
148166
149167Build your project as you normally would. Java class files will be created as usual in the bin/ directory.
150168JavaScript equivalents of these files will be created in the site/swingjs/j2s directory. You might have to
151- do a project refresh to see these site files.
169+ do a project refresh to see these site files. If you open one in Eclipse, notice that each time you build
170+ the project (for example by saving a changed Java file with Project...Save Automatically set), Eclipse
171+ will prompt you to reload this file with changes.
152172
153173Do take a look at the .js files created. You will notice that they are all the methods and fields of your
154- Java project *except* final static constants. SwingJS does not recreate those by name; it just uses them.
155- (The only thing this should affect is that java.lang.reflect.Field does not indicate these names.)
156-
174+ Java project *except* final static constants. SwingJS does not recreate final static constants by name;
175+ It just uses them. This means that the java.lang.reflect.Field methods will not indicate these names.
157176
158177----------------------------------------------
159178Testing the JavaScript version of your project
@@ -163,7 +182,34 @@ The J2S transpiler will automatically set up for you in site/ a sample HTML page
163182that subclasses JApplet or contains a public void main(String[] args) method. You will want to
164183associate those files with an external HTML browser. We recommend Firefox.
165184
166- Since you will be running AJAX locally within these browsers, you may need to enable local
185+ Do not change these files, as they will be recreated each time the transpiler runs. If you want
186+ a different configuration -- a different width or height, or some additional "applet" parameters,
187+ make a copy of this file and change within it the Info block:
188+
189+ Info = {
190+ code: _CODE_,
191+ main: _MAIN_,
192+ width: 850,
193+ height: 550,
194+ readyFunction: null,
195+ serverURL: 'https://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php',
196+ j2sPath: 'swingjs/j2s',
197+ console:'sysoutdiv',
198+ allowjavascript: true
199+ }
200+
201+ These Info key/value pairs are equivalent to Java applet parameters. Use Info.args for the main(args[])
202+ parameters. For instance:
203+
204+ args:["test","true"],
205+
206+ The serverURL reference allows for reading files in AJAX from servers that are not configured with
207+
208+ access-control-origin: *
209+
210+ You can try removing that if you want to.
211+
212+ Since you will be running AJAX locally within your browser, you may need to enable local
167213file reading in your browser. Instructions for doing that can be found at
168214http://wiki.jmol.org/index.php/Troubleshooting/Local_Files
169215
@@ -176,9 +222,13 @@ If you find you are missing a Java class, please contact me (Bob Hanson) at hans
176222You can try adding these yourself by **temporarily** adding one or more of the Java classes found
177223at http://grepcode.com to the proper package in your project. For example, java/awt.
178224
179- If you do that, be sure to use the OpenJDK version. Most of the code in the SwingJS project started with
180- Java 6-b14 or 6-b27. Build your project, then delete these Java files, because you do not necessarily
181- want your Java code using that version, just JavaScript.
225+ If you do that, be sure to use the OpenJDK version. For example:
226+
227+ http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes
228+
229+ Most of the code in the SwingJS project started with
230+ Java 6-b14 or 6-b27. Build your project, then delete these Java files, because, should this file be added
231+ to an updated verison of SwingJS, you should probably use the one provided, not your own. Your choice.
182232
183233
184234----------------
@@ -198,15 +248,20 @@ working site is https://chemapps.stolaf.edu/swingjs/physlets
198248
199249Phet applets have not been put on GitHub yet.
200250
251+ Note that these sites use an older v. 3.1.1 transpiler and runtime.
201252
253+ Feb. 17, 2018
202254
203- As of Feb. 17, 2018, we are actively converting a variety of functioning Java applets.
255+ We are actively converting a variety of functioning Java applets.
204256
205257The physlets Animator, Doppler, and Optics are working.
206258
207- As of Jan. 2, 2018, all known Java-to-JavaScript issues have been dealt with.
259+ Jan. 2, 2018
260+
208261Efficient Google Closure Compiler compression is in place.
209262
210- As of Dec. 17, 2017, SwingJS is fully operational in its "version 2" format,
263+ Dec. 17, 2017
264+
265+ SwingJS is fully operational in its "version 2" format (still v. 3.1.1),
211266which includes fully qualified method, array, and number typing.
212267
0 commit comments