Skip to content

Commit ef220c7

Browse files
hansonrhansonr
authored andcommitted
file refactoring in dist/ (2/2)
1 parent afcdbd0 commit ef220c7

File tree

13 files changed

+206
-38
lines changed

13 files changed

+206
-38
lines changed

sources/net.sf.j2s.core/dist/README.txt

Lines changed: 76 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
SwingJS distribution
1+
This is the main README file for the Java2Script/SwingJS distribution
22

3-
https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.core/dist/dropins/README.txt
3+
https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.core/dist/README.txt
44

5-
8/6/2018 Bob Hanson hansonr@stolaf.edu
5+
8/12/2018 Bob Hanson hansonr@stolaf.edu
66

7-
Java2Script 3.2.2.03 introduces and checks more Java 8 capabilities.
8-
Use
7+
The dist/dropins folder has been renamed dist/swingjs
8+
9+
https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.core/dist/swingjs
10+
11+
It holds the key files that are needed for a J2S project (see below).
12+
13+
14+
Java2Script 3.2.2.03 introduces and checks more Java 8 capabilities. Use
915

1016
eclipsec -clean
1117

@@ -26,22 +32,24 @@ This includes
2632
java.util.stream.*
2733
default methods in interfaces
2834

29-
All projects compiled under 3.1.1 need to be recompiled using the Java2Script 3.2.1 transpiler, as
35+
All projects compiled under 3.1.1 need to be recompiled using the Java2Script 3.2.x transpiler, as
3036
described below. Note that if you use /** @j2sNative */ calls to interface methods that are singlets,
31-
you no longer need to add qualifications (such as $O) to them. It should be no problem to leave them
37+
those methods all take just $ as a qualifier. It should be no problem to leave them
3238
qualified, though, as the transpiler creates qualified and unqualified aliases.
3339

34-
There are situations where this use of unqualified method names can run into problems. For example, in
35-
java.util.stream.ReferencePipeline, there are three different declarations of the functional interface
36-
method "accept". They were just for erro reporting and have been removed.
40+
There are occasional situations where this use of $-unqualified method names can run into problems.
41+
For example, in java.util.stream.ReferencePipeline, there are three different default declarations
42+
of the functional interface method "accept". They are just for error reporting and have been removed.
3743
My guess that this is a rarity, but I am not sure.
3844

39-
4045
SwingJS has been successfully tested in Eclipse version Neon-Photon on Mac and Windows platforms.
4146
(No reason to believe it would not also work for Linux; just haven't tried that recently.)
4247
Java 8 is the target Java version for transpilation. Please report any missing classes or strange
4348
errors.
4449

50+
51+
3/15/2018 Bob Hanson hansonr@stolaf.edu
52+
4553
net.sf.j2s.core_3.2.1.jar replaces net.sf.j2s.core_3.1.1.jar
4654

4755
These versions differ only in their internal workings relative to Eclipse.
@@ -51,19 +59,14 @@ the standard Eclipse java builder, org.eclipse.jdt.core.javabuilder.
5159

5260
For v. 3.2.1, to get started with SwingJS, all you need are:
5361

54-
1) the latest transpiler from
55-
56-
https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.core/dist/dropins
57-
58-
2) the latest JavaScript-site.zip from
62+
1) the latest transpiler (net.sf.j2s.core.jar) and run-time (Swingjs-site.zip) from
5963

60-
https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.java.core/dist
64+
https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.core/dist/swingjs
6165

62-
3) an empty .j2s file in your project directory. (The v.3.2.1 transpiler will fill this in with
63-
a default .j2s configuration when it runs the first time.)
66+
2) an empty .j2s file in your project directory. (The Java2Script transpiler will fill this in with
67+
a default .j2s configuration when it runs the first time. Or, you could use the one in /dist to start)
6468

65-
66-
NOTE! If you are updating to 3.2.1 from 3.1.1, be sure to open your .project file and change the
69+
NOTE! If you are updating to 3.2.x from 3.1.1, be sure to open your .project file and change the
6770
builder name from net.sf.j2s.core.java2scriptbuilder back to org.eclipse.jdt.core.javabuilder
6871
or your project will no longer compile.
6972

@@ -89,22 +92,48 @@ that match the standard .class files created by the Eclipse Java compiler itself
8992
Note that both Java .class files (in bin/) and JavaScript .js files (in site/swingjs/j2s) are
9093
created automatically anytime you do any building of your project.
9194

95+
The easiest thing to do is to copy the contents of the dist/ directory
96+
97+
https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.core/dist
98+
99+
into your project directory. It contains the following directories:
100+
101+
swingjs/
102+
-- contains the necessary Eclipse drop-in as well as the run-time
103+
-- ver/ subfolder holds older versions
104+
tools/
105+
-- contains ant-contrib.jar, used by build-site.xml
106+
libjs/
107+
-- empty; reserved for foo.zip equivalents of dependency foo.jar files
108+
-- these will be unzipped into site/ by build-site.xml
109+
resources/
110+
-- empty; reserved for non-java resources your program might need
111+
-- these will go into site/swingjs/j2s by build-site.xml
112+
113+
and files:
114+
115+
.j2s -- a starter j2s configuration file
116+
build-site.xml -- run this to build the site/ directory before or after you
117+
update your Java code.
118+
119+
120+
The following instructions include instructions for doing some of this manually:
92121

93122
1. Copy net.sf.j2s.core.jar from
94123

95-
https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.core/dist/dropins
124+
https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.core/dist/swingjs
96125

97126
specifically:
98127

99-
https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.core/dist/dropins/net.sf.j2s.core.jar?raw=true
128+
https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.core/dist/swingjs/net.sf.j2s.core.jar?raw=true
100129

101130
into your eclipse/dropins directory.
102131

103132
Also provided in that directory is a ver/ directory with previous core files.
104-
It is recommended that you not use them. If you do, be sure to remove their _x.x.x version
105-
signature from their file name, or some versions of Eclipse will have to be
106-
entirely reinstalled every time you change versions. We do not know why this is necessary,
107-
but it appears to be. This is an Eclipse bug. So just always use dist/dropins/net.sf.j2s.core.jar.
133+
These files have names that are purposely unversioned because some versions of Eclipse
134+
will have to be entirely reinstalled every time you change versions if the names are different
135+
from version to version. We do not know why this is necessary, but it appears to be.
136+
This is an Eclipse bug. So just always use dist/swingjs/net.sf.j2s.core.jar.
108137

109138
On Mac systems, the Eclipse directory is generally
110139

@@ -117,7 +146,7 @@ Search for "j2s" to find j2s.sourceforge.net Java2Script Core
117146

118147
If that is not there, you don't have net.sf.j2s.core.jar in the proper directory.
119148

120-
Note relating to updating to 3.2.1 from 3.1.1 version of Java2Script:
149+
Note relating to updating to 3.2.x from 3.1.1 version of Java2Script:
121150

122151
If the version on this readout does not match the version that is
123152
reported at the end of each .js file created:
@@ -127,8 +156,7 @@ If that is not there, you don't have net.sf.j2s.core.jar in the proper directory
127156
then there is no real problem, but you can correct that by restarting
128157
Eclipse once with the -clean flag.
129158

130-
131-
159+
132160
----------------------------------
133161
Creating a new J2S/SwingJS project
134162
----------------------------------
@@ -145,11 +173,17 @@ All source code must be available. (Source code from decompiling .class files wi
145173
Installing the SwingJS JavaScript version of the Java Virtual Machine
146174
---------------------------------------------------------------------
147175

176+
Chrome users should consider using WebServer for Chrome to serve local files. It is very
177+
simple to set up.
178+
179+
https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb?hl=en
180+
181+
148182
All of the JavaScript produced will be in the project site/ directory.
149183
You must prepopulate this site with all the JavaScript required by the
150184
JavaScript version of the JVM. The most recent version of site/ is at
151185

152-
https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.java.core/dist/SwingJS-site.zip?raw=true
186+
https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip?raw=true
153187

154188
Occasional additions to the java.* classes are made to the above-mentioned zip file.
155189

@@ -211,6 +245,13 @@ Info = {
211245
allowjavascript: true
212246
}
213247

248+
You can add
249+
250+
core: "NONE",
251+
252+
to that to prevent the use of core/coreswingjs.z.js and make life easier for yourself
253+
while debugging.
254+
214255
These Info key/value pairs are equivalent to Java applet parameters. Use Info.args for the main(args[])
215256
parameters. For instance:
216257

@@ -239,10 +280,11 @@ If you do that, be sure to use the OpenJDK version. For example:
239280

240281
http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes
241282

242-
Most of the code in the SwingJS project started with
243-
Java 6-b14 or 6-b27. Build your project, then delete these Java files, because, should this file be added
244-
to an updated verison of SwingJS, you should probably use the one provided, not your own. Your choice.
283+
Most of the code in the SwingJS project started with Java 6-b14 or 6-b27. The goal is to
284+
move these all to Java8 OpenJDK versions.
245285

286+
Build your project, then delete these Java files, because, should this file be added
287+
to an updated version of SwingJS, you should probably use the one provided, not your own. Your choice.
246288

247289
----------------
248290
Working projects
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
BH 2018.08.12
4+
5+
- requires tools/ant-contrib.jar
6+
7+
- creates the site/ directory if it does not exist
8+
- unzip libjs/*.zip into site/swingjs/j2s
9+
- unzips swingjs/SwingJS-site.zip into site/
10+
- copies non-java resources from resources/ into site/swingjs/j2s
11+
12+
-->
13+
14+
<project name="swingjs-project" default="tosite" basedir="."
15+
xmlns:if="ant:if"
16+
xmlns:unless="ant:unless">
17+
18+
<target name="tosite">
19+
20+
<!-- input directories -->
21+
22+
<!-- location of ant-contrib.jar -->
23+
<property name="tools.dir" value = "tools" />
24+
25+
<!-- SwingjS_site zip file (could be varied if versioning is needed) -->
26+
<property name="swingjs.zip" value="swingjs/SwingJS-site.zip" />
27+
28+
<!-- location of third-party jar contents as precompiled zipped .js files to copy to site/ -->
29+
<property name="libjs.dir" value="libjs" />
30+
31+
<!-- non-Java resources to copy to site/ -->
32+
<property name="resource.dir" value="resources" />
33+
34+
<!-- output directories -->
35+
36+
<property name="site.dir" value="site" />
37+
<property name="j2s.dir" value="${site.dir}/swingjs/j2s" />
38+
39+
<!-- <for ...> construct needs ant-contrib.jar -->
40+
<taskdef resource="net/sf/antcontrib/antlib.xml">
41+
<classpath>
42+
<pathelement location="${tools.dir}/ant-contrib.jar" />
43+
</classpath>
44+
</taskdef>
45+
46+
<!-- unzip all libjs zip files into site
47+
48+
all zip files placed in libjs will be processed
49+
50+
-->
51+
52+
<for param="file.zip">
53+
<path>
54+
<fileset dir="${libjs.dir}" includes="*.zip"/>
55+
</path>
56+
<sequential>
57+
<unzip src="@{file.zip}" dest="${site.dir}" overwrite="true"/>
58+
</sequential>
59+
</for>
60+
61+
<!-- unzip SwingJS-site.zip
62+
63+
we do this separately, as we want it done last
64+
65+
-->
66+
67+
<unzip src="${swingjs.zip}" dest="${site.dir}/" overwrite="true"/>
68+
69+
<!-- transfer resources -->
70+
71+
<echo> Copying ${resource.dir} files into ${j2s.dir} </echo>
72+
<copy todir="${j2s.dir}">
73+
<fileset dir="${resource.dir}">
74+
<include name="**"/>
75+
</fileset>
76+
</copy>
77+
78+
</target>
79+
80+
81+
</project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
SwingJS distribution -- libjs directory
2+
3+
This directory can be used to hold pre-compiled *.zip files that
4+
have root directories swingjs and swingjs/j2s. They will be
5+
unzipped into the site/ directory by build-site.xml.
6+
7+
Generally these files would be derived from .jar files that your
8+
program uses. If your program has jar dependencies, you will need to
9+
find the source for those, compile it, and then zip the resulting
10+
.js files into xxxx.zip. The ANT task that might do this should look
11+
something like this:
12+
13+
<target name="zipjson">
14+
<!-- org.json.simple -->
15+
<property name="json.zip" value="${libjs.dir}/jsonsimple-site.zip" />
16+
<echo> Zipping up ${json.zip} </echo>
17+
<zip destfile="${json.zip}" basedir="${site.dir}" includes="swingjs/j2s/org/json/**" />
18+
</target>
19+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SwingJS distribution -- resources directory
2+
3+
This directory can be used to hold non-Java files that your program
4+
needs to run -- data files, for instance. Files in it will be copied to
5+
the site/ directory by build-site.xml.
6+
459 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20180812000515
1+
20180812102716
459 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20180812000515
1+
20180812102716
190 KB
Binary file not shown.
459 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)