├── .gitattributes
├── .gitignore
├── .gitpitch
├── 1.jpg
├── 2.jpg
└── 3.jpg
├── .travis.yml
├── LICENSE
├── PITCHME.md
├── README.md
├── build.xml
├── dist
└── n4j.snippet.java
├── docs
├── favicon.ico
├── index.html
├── localhost.port.0.5.0
│ ├── _meta_.skeleton.html
│ ├── examples.html
│ ├── execution.history.html
│ ├── executionHistory.js
│ ├── favicon.ico
│ ├── index.html
│ ├── main.css
│ ├── milligram.css
│ ├── nudge4j.32x32.png
│ ├── nudge4j.js
│ ├── remote.console.css
│ ├── remote.console.html
│ └── remote.console.js
├── milligram.css
├── n4j.png
└── twigs
│ ├── dump.all.classes.js
│ ├── get.JVM.info.js
│ ├── get.class.path.js
│ ├── get.thread.dump.js
│ ├── get.thread.x.cpu.js
│ ├── laserBeam.js
│ ├── n4j.boot.js
│ └── readme.txt
├── n4j.in.action.gif
└── src
└── nudge4j
└── N4J.java
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.js linguist-language=Java
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 | .classpath
3 | .project
4 |
--------------------------------------------------------------------------------
/.gitpitch/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lorenzoongithub/nudge4j/c65ee69943097756cf07a336e8ebae1fe923a21a/.gitpitch/1.jpg
--------------------------------------------------------------------------------
/.gitpitch/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lorenzoongithub/nudge4j/c65ee69943097756cf07a336e8ebae1fe923a21a/.gitpitch/2.jpg
--------------------------------------------------------------------------------
/.gitpitch/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lorenzoongithub/nudge4j/c65ee69943097756cf07a336e8ebae1fe923a21a/.gitpitch/3.jpg
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | jdk:
3 | - oraclejdk9
4 |
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 lorenzo puccetti
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/PITCHME.md:
--------------------------------------------------------------------------------
1 | 
2 | #HSLIDE
3 | 
4 | #HSLIDE
5 | 
6 | #HSLIDE
7 | Try [nudge4j](https://lorenzoongithub.github.io/nudge4j/ "nudge4j")
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # [nudge4j](https://lorenzoongithub.github.io/nudge4j/) · [](https://travis-ci.org/lorenzoongithub/nudge4j) [](https://gitpitch.com/lorenzoongithub/nudge4j/master?grs=github&t=white) [](https://opensource.org/licenses/MIT)
2 |
3 | nudge4j is a tiny piece of code to help great developers understand code better, debug less, have more fun.
4 |
5 |
6 | ## Overview
7 |
8 | With nudge4j you can:
9 |
10 | - control your Java application from the browser, as if the browser was a smarter remote control.
11 | - send code from the browser to run on the JVM,
12 | - experiment with live code.
13 |
14 |
15 | To use nudge4j, just add [less than 10 lines of code](https://lorenzoongithub.github.io/nudge4j/index.html#Usenudge4j) in your program.
16 |
17 |
18 |
19 | ## Issues
20 |
21 | Report any issue using GitHub and use notifications to track progress on them.
22 |
23 | ## Contributing
24 |
25 | Want to hack on this project? Any kind of contribution is welcome! But I am particularly interested in Nashorn/JavaScript samples to add in the example section.
26 |
27 | ## License
28 |
29 | This project is licensed under the MIT license.
30 |
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | smoke test: java compilation
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/dist/n4j.snippet.java:
--------------------------------------------------------------------------------
1 | // nudge4j - bootstrap
2 | try {
3 | new javax.script.ScriptEngineManager()
4 | .getEngineByName("JavaScript")
5 | .eval("load('https://lorenzoongithub.github.io/nudge4j/twigs/n4j.boot.js')");
6 | } catch (javax.script.ScriptException e) {
7 | throw new RuntimeException(e);
8 | }
--------------------------------------------------------------------------------
/docs/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lorenzoongithub/nudge4j/c65ee69943097756cf07a336e8ebae1fe923a21a/docs/favicon.ico
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | nudge4j - home
12 |
13 |
14 |
15 |
nudge4j - Get Inside Your JVM
16 |
nudge4j gives you few lines of Java code to make your Java application accessible to the browser .
17 | It's meant for use during development to provide an environment for experimenting with code against a running application.
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
Use nudge4j
29 |
30 | Add the following code to your Java Application and start using nudge4j. If possible, you should add the code as the first line of your public static void main method.
31 |
32 |
33 |
34 |
35 |
36 |
37 | It really is that simple: no jar to download, no classpath to modify and no pom to alter.
38 | Once you are done with it, either remove the code or comment it out.
39 |
40 |
41 |
42 |
First Steps
43 |
44 | Once the snippet has been integrated into your program, try this:
45 |
http://localhost:5050/
46 |
47 | Alternatively, you can read a little bit more
48 | here ,
49 | here
50 | and here .
51 |
52 |
53 |
54 |
64 |
65 |
Requirements
66 |
67 | Java 8
68 | Internet access many resources are hosted on GitHub and various other CDNs
69 | A modern browser (Chrome, Firefox, IE11+)
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/docs/localhost.port.0.5.0/_meta_.skeleton.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | nudge4j - (meta) skeleton
13 |
14 |
15 |
16 |
17 |
18 |
skeleton
19 |
20 | This is an example page on how we build every web page.
21 | In particular, in the head we only change the title.
22 | In the body we create always an njHeader and an njCore which is made of 1 or more njContainer s separated by njSeparator s.
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/docs/localhost.port.0.5.0/examples.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | nudge4j - examples
13 |
14 |
15 |
16 |
17 |
18 |
Examples
19 | The best snippets are probably going to be the ones you are going to write.
20 | Because they can be specific to your application and access packages and classes that only you know of.
21 |
22 | Yet, here is some sample code that shows how we get inside the JVM, to get you started.
23 |
24 |
25 | Now
26 | - Showing how to invoke any static method
27 | System.out/err
28 | - hello world
29 | List
30 | - Showing how to build any JDK object
31 | Binary
32 | - Looping is testing
33 |
34 |
35 |
36 |
37 |
38 |
39 |
//
40 | // You can call any static method.
41 | // java.time.LocalDate is the fully qualified class
42 | // and now() is the static method.
43 | //
44 | java.time.LocalDate.now();
45 |
46 |
//
47 | // writing on the logs.
48 | //
49 | java.lang.System.out.println('Hello world');
50 | java.lang.System.err.println('and Hello world (again)');
51 | 'check your JVM logs'
52 |
53 |
//
54 | // Building a Java Object is easy
55 | //
56 | var list = new java.util.ArrayList();
57 | list.add('apple');
58 | list.add('banana');
59 | list.add('cherry');
60 | list;
61 |
62 |
// did you know that Integer had a static 'toBinaryString' method ?
63 | var str='';
64 | for (var i=0;i<16;i++) {
65 | str+=i+' '+java.lang.Integer.toBinaryString(i)+'\n'
66 | }
67 | str;
68 |
69 |
76 |
77 |
--------------------------------------------------------------------------------
/docs/localhost.port.0.5.0/execution.history.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | nudge4j - execution history
13 |
14 |
15 |
16 |
17 |
18 |
Execution History
19 |
20 |
21 |
22 |
23 |
24 |
58 |
59 |
--------------------------------------------------------------------------------
/docs/localhost.port.0.5.0/executionHistory.js:
--------------------------------------------------------------------------------
1 |
2 | var executionHistory = (function() {
3 | var v = localStorage.getItem('executionHistory');
4 | var array = (v != null) ? JSON.parse(v) : [];
5 |
6 | return {
7 | push : function push(code) {
8 | array.push({time: new Date().getTime(), code : code});
9 | localStorage.setItem('executionHistory', JSON.stringify(array));
10 | },
11 |
12 | count : function() { return array.length; },
13 | get : function(i) { return array[i]; },
14 | remove : function(i) {
15 | array.splice(i,1);
16 | localStorage.setItem('executionHistory', JSON.stringify(array));
17 | }
18 | };
19 | })();
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/docs/localhost.port.0.5.0/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lorenzoongithub/nudge4j/c65ee69943097756cf07a336e8ebae1fe923a21a/docs/localhost.port.0.5.0/favicon.ico
--------------------------------------------------------------------------------
/docs/localhost.port.0.5.0/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | nudge4j - home
13 |
14 |
15 |
16 |
17 |
18 |
Dashboard
19 |
20 |
21 |
22 | JVM
23 | ...
24 |
25 |
26 | Uptime
27 | ...
28 |
29 |
30 | Hook
31 | ...
32 |
33 |
34 | Static URL
35 | ...
36 |
37 |
38 |
39 |
40 |
41 |
42 |
Remote Console
43 | The remote console lets you send code to execute on your JVM. For your convenience any code which you execute is also stored on your browser's local storage,
44 | so that it's going to be hard to lose it.
45 |
46 |
50 |
51 |
52 |
55 |
56 |
57 |
HTTP API
58 |
59 | At its core, nudge4j is just a tiny web server.
60 | All API access is over HTTP, and accessed from
http://localhost:[port]/js?code=[code]
61 | All data is sent with Content-Type: text/plain; charset=utf-8
62 |
63 |
64 | curl -i "http://localhost:5050/js?code=1000-1"
65 | HTTP/1.1 200 OK
66 | Date: Sat, 26 May 2018 23:15:30 GMT
67 | Content-type: text/plain
68 | Content-length: 3
69 | Cache-control: no-cache
70 | 999
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
86 |
87 |
88 |
89 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/docs/localhost.port.0.5.0/main.css:
--------------------------------------------------------------------------------
1 | /**
2 | * The CSS on top of 'milligram'
3 | *
4 | **/
5 | #njHeader {
6 | background-color:#fff;
7 | border-bottom:1px solid #888;
8 | padding:2.0rem;
9 | height:6.5rem;
10 | position:fixed;
11 | top:0;
12 | left:0;
13 | right:0;
14 | }
15 |
16 | #njCore {
17 | padding:2.0rem;
18 | position:fixed;
19 | top:6.5rem;
20 | bottom:0;
21 | left:0;
22 | right:0;
23 | overflow:auto;
24 | }
25 |
26 | .njContainer {
27 | border:1px solid #888;
28 | background-color:white;
29 | padding:1.0rem;
30 | overflow:hidden;
31 | }
32 |
33 | .njSeparator {
34 | height:2.0rem;
35 | }
36 |
37 | /**
38 | HERE WE OVERRIDE milligram
39 | **/
40 |
41 | body {
42 | background-color:#f5f7fb;
43 | }
44 |
45 |
46 | /** do we want this text-decoration ? **/
47 | a {text-decoration:none}
48 | a:hover,a:focus {text-decoration:underline}
49 |
50 | pre {
51 | border: 0;
52 | background-color: #fff;
53 | }
54 |
55 | td {
56 | vertical-align: top;
57 | }
--------------------------------------------------------------------------------
/docs/localhost.port.0.5.0/milligram.css:
--------------------------------------------------------------------------------
1 | /*!
2 | * Milligram v1.3.0
3 | * https://milligram.github.io
4 | *
5 | * Copyright (c) 2018 CJ Patoilo
6 | * Licensed under the MIT license
7 | *
8 | * REPLACING:
9 |
10 | * #9b4 dca --> #428bca; // purple with a blueish
11 | * #606 c76 --> #2a6496; // gray (used when hovering) with another blueish
12 | */
13 |
14 | *,
15 | *:after,
16 | *:before {
17 | box-sizing: inherit;
18 | }
19 |
20 | html {
21 | box-sizing: border-box;
22 | font-size: 62.5%;
23 | }
24 |
25 | body {
26 | color: #2a6496;;
27 | font-family: 'Roboto', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
28 | font-size: 1.6em;
29 | font-weight: 300;
30 | letter-spacing: .01em;
31 | line-height: 1.6;
32 | }
33 |
34 | blockquote {
35 | border-left: 0.3rem solid #d1d1d1;
36 | margin-left: 0;
37 | margin-right: 0;
38 | padding: 1rem 1.5rem;
39 | }
40 |
41 | blockquote *:last-child {
42 | margin-bottom: 0;
43 | }
44 |
45 | .button,
46 | button,
47 | input[type='button'],
48 | input[type='reset'],
49 | input[type='submit'] {
50 | background-color: #428bca;
51 | border: 0.1rem solid #428bca;
52 | border-radius: .4rem;
53 | color: #fff;
54 | cursor: pointer;
55 | display: inline-block;
56 | font-size: 1.1rem;
57 | font-weight: 700;
58 | height: 3.8rem;
59 | letter-spacing: .1rem;
60 | line-height: 3.8rem;
61 | padding: 0 3.0rem;
62 | text-align: center;
63 | text-decoration: none;
64 | text-transform: uppercase;
65 | white-space: nowrap;
66 | }
67 |
68 | .button:focus, .button:hover,
69 | button:focus,
70 | button:hover,
71 | input[type='button']:focus,
72 | input[type='button']:hover,
73 | input[type='reset']:focus,
74 | input[type='reset']:hover,
75 | input[type='submit']:focus,
76 | input[type='submit']:hover {
77 | background-color: #2a6496;;
78 | border-color: #2a6496;;
79 | color: #fff;
80 | outline: 0;
81 | }
82 |
83 | .button[disabled],
84 | button[disabled],
85 | input[type='button'][disabled],
86 | input[type='reset'][disabled],
87 | input[type='submit'][disabled] {
88 | cursor: default;
89 | opacity: .5;
90 | }
91 |
92 | .button[disabled]:focus, .button[disabled]:hover,
93 | button[disabled]:focus,
94 | button[disabled]:hover,
95 | input[type='button'][disabled]:focus,
96 | input[type='button'][disabled]:hover,
97 | input[type='reset'][disabled]:focus,
98 | input[type='reset'][disabled]:hover,
99 | input[type='submit'][disabled]:focus,
100 | input[type='submit'][disabled]:hover {
101 | background-color: #428bca;
102 | border-color: #428bca;
103 | }
104 |
105 | .button.button-outline,
106 | button.button-outline,
107 | input[type='button'].button-outline,
108 | input[type='reset'].button-outline,
109 | input[type='submit'].button-outline {
110 | background-color: transparent;
111 | color: #428bca;
112 | }
113 |
114 | .button.button-outline:focus, .button.button-outline:hover,
115 | button.button-outline:focus,
116 | button.button-outline:hover,
117 | input[type='button'].button-outline:focus,
118 | input[type='button'].button-outline:hover,
119 | input[type='reset'].button-outline:focus,
120 | input[type='reset'].button-outline:hover,
121 | input[type='submit'].button-outline:focus,
122 | input[type='submit'].button-outline:hover {
123 | background-color: transparent;
124 | border-color: #2a6496;;
125 | color: #2a6496;;
126 | }
127 |
128 | .button.button-outline[disabled]:focus, .button.button-outline[disabled]:hover,
129 | button.button-outline[disabled]:focus,
130 | button.button-outline[disabled]:hover,
131 | input[type='button'].button-outline[disabled]:focus,
132 | input[type='button'].button-outline[disabled]:hover,
133 | input[type='reset'].button-outline[disabled]:focus,
134 | input[type='reset'].button-outline[disabled]:hover,
135 | input[type='submit'].button-outline[disabled]:focus,
136 | input[type='submit'].button-outline[disabled]:hover {
137 | border-color: inherit;
138 | color: #428bca;
139 | }
140 |
141 | .button.button-clear,
142 | button.button-clear,
143 | input[type='button'].button-clear,
144 | input[type='reset'].button-clear,
145 | input[type='submit'].button-clear {
146 | background-color: transparent;
147 | border-color: transparent;
148 | color: #428bca;
149 | }
150 |
151 | .button.button-clear:focus, .button.button-clear:hover,
152 | button.button-clear:focus,
153 | button.button-clear:hover,
154 | input[type='button'].button-clear:focus,
155 | input[type='button'].button-clear:hover,
156 | input[type='reset'].button-clear:focus,
157 | input[type='reset'].button-clear:hover,
158 | input[type='submit'].button-clear:focus,
159 | input[type='submit'].button-clear:hover {
160 | background-color: transparent;
161 | border-color: transparent;
162 | color: #2a6496;;
163 | }
164 |
165 | .button.button-clear[disabled]:focus, .button.button-clear[disabled]:hover,
166 | button.button-clear[disabled]:focus,
167 | button.button-clear[disabled]:hover,
168 | input[type='button'].button-clear[disabled]:focus,
169 | input[type='button'].button-clear[disabled]:hover,
170 | input[type='reset'].button-clear[disabled]:focus,
171 | input[type='reset'].button-clear[disabled]:hover,
172 | input[type='submit'].button-clear[disabled]:focus,
173 | input[type='submit'].button-clear[disabled]:hover {
174 | color: #428bca;
175 | }
176 |
177 | code {
178 | background: #f4f5f6;
179 | border-radius: .4rem;
180 | font-size: 86%;
181 | margin: 0 .2rem;
182 | padding: .2rem .5rem;
183 | white-space: nowrap;
184 | }
185 |
186 | pre {
187 | background: #f4f5f6;
188 | border-left: 0.3rem solid #428bca;
189 | overflow-y: hidden;
190 | }
191 |
192 | pre > code {
193 | border-radius: 0;
194 | display: block;
195 | padding: 1rem 1.5rem;
196 | white-space: pre;
197 | }
198 |
199 | hr {
200 | border: 0;
201 | border-top: 0.1rem solid #f4f5f6;
202 | margin: 3.0rem 0;
203 | }
204 |
205 | input[type='email'],
206 | input[type='number'],
207 | input[type='password'],
208 | input[type='search'],
209 | input[type='tel'],
210 | input[type='text'],
211 | input[type='url'],
212 | input[type='color'],
213 | input[type='date'],
214 | input[type='month'],
215 | input[type='week'],
216 | input[type='datetime'],
217 | input[type='datetime-local'],
218 | input:not([type]),
219 | textarea,
220 | select {
221 | -webkit-appearance: none;
222 | -moz-appearance: none;
223 | appearance: none;
224 | background-color: transparent;
225 | border: 0.1rem solid #d1d1d1;
226 | border-radius: .4rem;
227 | box-shadow: none;
228 | box-sizing: inherit;
229 | height: 3.8rem;
230 | padding: .6rem 1.0rem;
231 | width: 100%;
232 | }
233 |
234 | input[type='email']:focus,
235 | input[type='number']:focus,
236 | input[type='password']:focus,
237 | input[type='search']:focus,
238 | input[type='tel']:focus,
239 | input[type='text']:focus,
240 | input[type='url']:focus,
241 | input[type='color']:focus,
242 | input[type='date']:focus,
243 | input[type='month']:focus,
244 | input[type='week']:focus,
245 | input[type='datetime']:focus,
246 | input[type='datetime-local']:focus,
247 | input:not([type]):focus,
248 | textarea:focus,
249 | select:focus {
250 | border-color: #428bca;
251 | outline: 0;
252 | }
253 |
254 | select {
255 | background: url('data:image/svg+xml;utf8, ') center right no-repeat;
256 | padding-right: 3.0rem;
257 | }
258 |
259 | select:focus {
260 | background-image: url('data:image/svg+xml;utf8, ');
261 | }
262 |
263 | textarea {
264 | min-height: 6.5rem;
265 | }
266 |
267 | label,
268 | legend {
269 | display: block;
270 | font-size: 1.6rem;
271 | font-weight: 700;
272 | margin-bottom: .5rem;
273 | }
274 |
275 | fieldset {
276 | border-width: 0;
277 | padding: 0;
278 | }
279 |
280 | input[type='checkbox'],
281 | input[type='radio'] {
282 | display: inline;
283 | }
284 |
285 | .label-inline {
286 | display: inline-block;
287 | font-weight: normal;
288 | margin-left: .5rem;
289 | }
290 |
291 | .container {
292 | margin: 0 auto;
293 | max-width: 112.0rem;
294 | padding: 0 2.0rem;
295 | position: relative;
296 | width: 100%;
297 | }
298 |
299 | .row {
300 | display: flex;
301 | flex-direction: column;
302 | padding: 0;
303 | width: 100%;
304 | }
305 |
306 | .row.row-no-padding {
307 | padding: 0;
308 | }
309 |
310 | .row.row-no-padding > .column {
311 | padding: 0;
312 | }
313 |
314 | .row.row-wrap {
315 | flex-wrap: wrap;
316 | }
317 |
318 | .row.row-top {
319 | align-items: flex-start;
320 | }
321 |
322 | .row.row-bottom {
323 | align-items: flex-end;
324 | }
325 |
326 | .row.row-center {
327 | align-items: center;
328 | }
329 |
330 | .row.row-stretch {
331 | align-items: stretch;
332 | }
333 |
334 | .row.row-baseline {
335 | align-items: baseline;
336 | }
337 |
338 | .row .column {
339 | display: block;
340 | flex: 1 1 auto;
341 | margin-left: 0;
342 | max-width: 100%;
343 | width: 100%;
344 | }
345 |
346 | .row .column.column-offset-10 {
347 | margin-left: 10%;
348 | }
349 |
350 | .row .column.column-offset-20 {
351 | margin-left: 20%;
352 | }
353 |
354 | .row .column.column-offset-25 {
355 | margin-left: 25%;
356 | }
357 |
358 | .row .column.column-offset-33, .row .column.column-offset-34 {
359 | margin-left: 33.3333%;
360 | }
361 |
362 | .row .column.column-offset-50 {
363 | margin-left: 50%;
364 | }
365 |
366 | .row .column.column-offset-66, .row .column.column-offset-67 {
367 | margin-left: 66.6666%;
368 | }
369 |
370 | .row .column.column-offset-75 {
371 | margin-left: 75%;
372 | }
373 |
374 | .row .column.column-offset-80 {
375 | margin-left: 80%;
376 | }
377 |
378 | .row .column.column-offset-90 {
379 | margin-left: 90%;
380 | }
381 |
382 | .row .column.column-10 {
383 | flex: 0 0 10%;
384 | max-width: 10%;
385 | }
386 |
387 | .row .column.column-20 {
388 | flex: 0 0 20%;
389 | max-width: 20%;
390 | }
391 |
392 | .row .column.column-25 {
393 | flex: 0 0 25%;
394 | max-width: 25%;
395 | }
396 |
397 | .row .column.column-33, .row .column.column-34 {
398 | flex: 0 0 33.3333%;
399 | max-width: 33.3333%;
400 | }
401 |
402 | .row .column.column-40 {
403 | flex: 0 0 40%;
404 | max-width: 40%;
405 | }
406 |
407 | .row .column.column-50 {
408 | flex: 0 0 50%;
409 | max-width: 50%;
410 | }
411 |
412 | .row .column.column-60 {
413 | flex: 0 0 60%;
414 | max-width: 60%;
415 | }
416 |
417 | .row .column.column-66, .row .column.column-67 {
418 | flex: 0 0 66.6666%;
419 | max-width: 66.6666%;
420 | }
421 |
422 | .row .column.column-75 {
423 | flex: 0 0 75%;
424 | max-width: 75%;
425 | }
426 |
427 | .row .column.column-80 {
428 | flex: 0 0 80%;
429 | max-width: 80%;
430 | }
431 |
432 | .row .column.column-90 {
433 | flex: 0 0 90%;
434 | max-width: 90%;
435 | }
436 |
437 | .row .column .column-top {
438 | align-self: flex-start;
439 | }
440 |
441 | .row .column .column-bottom {
442 | align-self: flex-end;
443 | }
444 |
445 | .row .column .column-center {
446 | -ms-grid-row-align: center;
447 | align-self: center;
448 | }
449 |
450 | @media (min-width: 40rem) {
451 | .row {
452 | flex-direction: row;
453 | margin-left: -1.0rem;
454 | width: calc(100% + 2.0rem);
455 | }
456 | .row .column {
457 | margin-bottom: inherit;
458 | padding: 0 1.0rem;
459 | }
460 | }
461 |
462 | a {
463 | color: #428bca;
464 | text-decoration: none;
465 | }
466 |
467 | a:focus, a:hover {
468 | color: #2a6496;;
469 | }
470 |
471 | dl,
472 | ol,
473 | ul {
474 | list-style: none;
475 | margin-top: 0;
476 | padding-left: 0;
477 | }
478 |
479 | dl dl,
480 | dl ol,
481 | dl ul,
482 | ol dl,
483 | ol ol,
484 | ol ul,
485 | ul dl,
486 | ul ol,
487 | ul ul {
488 | font-size: 90%;
489 | margin: 1.5rem 0 1.5rem 3.0rem;
490 | }
491 |
492 | ol {
493 | list-style: decimal inside;
494 | }
495 |
496 | ul {
497 | list-style: circle inside;
498 | }
499 |
500 | .button,
501 | button,
502 | dd,
503 | dt,
504 | li {
505 | margin-bottom: 1.0rem;
506 | }
507 |
508 | fieldset,
509 | input,
510 | select,
511 | textarea {
512 | margin-bottom: 1.5rem;
513 | }
514 |
515 | blockquote,
516 | dl,
517 | figure,
518 | form,
519 | ol,
520 | p,
521 | pre,
522 | table,
523 | ul {
524 | margin-bottom: 2.5rem;
525 | }
526 |
527 | table {
528 | border-spacing: 0;
529 | width: 100%;
530 | }
531 |
532 | td,
533 | th {
534 | border-bottom: 0.1rem solid #e1e1e1;
535 | padding: 1.2rem 1.5rem;
536 | text-align: left;
537 | }
538 |
539 | td:first-child,
540 | th:first-child {
541 | padding-left: 0;
542 | }
543 |
544 | td:last-child,
545 | th:last-child {
546 | padding-right: 0;
547 | }
548 |
549 | b,
550 | strong {
551 | font-weight: bold;
552 | }
553 |
554 | p {
555 | margin-top: 0;
556 | }
557 |
558 | h1,
559 | h2,
560 | h3,
561 | h4,
562 | h5,
563 | h6 {
564 | font-weight: 300;
565 | letter-spacing: -.1rem;
566 | margin-bottom: 2.0rem;
567 | margin-top: 0;
568 | }
569 |
570 | h1 {
571 | font-size: 4.6rem;
572 | line-height: 1.2;
573 | }
574 |
575 | h2 {
576 | font-size: 3.6rem;
577 | line-height: 1.25;
578 | }
579 |
580 | h3 {
581 | font-size: 2.8rem;
582 | line-height: 1.3;
583 | }
584 |
585 | h4 {
586 | font-size: 2.2rem;
587 | letter-spacing: -.08rem;
588 | line-height: 1.35;
589 | }
590 |
591 | h5 {
592 | font-size: 1.8rem;
593 | letter-spacing: -.05rem;
594 | line-height: 1.5;
595 | }
596 |
597 | h6 {
598 | font-size: 1.6rem;
599 | letter-spacing: 0;
600 | line-height: 1.4;
601 | }
602 |
603 | img {
604 | max-width: 100%;
605 | }
606 |
607 | .clearfix:after {
608 | clear: both;
609 | content: ' ';
610 | display: table;
611 | }
612 |
613 | .float-left {
614 | float: left;
615 | }
616 |
617 | .float-right {
618 | float: right;
619 | }
--------------------------------------------------------------------------------
/docs/localhost.port.0.5.0/nudge4j.32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lorenzoongithub/nudge4j/c65ee69943097756cf07a336e8ebae1fe923a21a/docs/localhost.port.0.5.0/nudge4j.32x32.png
--------------------------------------------------------------------------------
/docs/localhost.port.0.5.0/nudge4j.js:
--------------------------------------------------------------------------------
1 | //
2 | // nudge4j.js defines a global object named n4j
3 | // n4j is used to communicate (AJAX) with the webserver started by nudge4j java snippet.
4 | // n4j.execCode(code, callback) --> send the code at the webserver's URL (e.g. http://localhost:5050)
5 | // n4j.execFunc(func, arg, callback) --> serializes the function and the argument into a code which is then passed to execCode
6 | //
7 | var n4j = {};
8 |
9 | n4j.execCode = function(code, callback) {
10 | var x = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
11 | x.onreadystatechange = function() {
12 | if (x.readyState != 4) {
13 | return;
14 | }
15 | if (x.status == 200) {
16 | if (x.responseText.substring(0,5)==='err::') {
17 | callback(x.responseText.substring(5),null);
18 | } else {
19 | callback(null,x.responseText);
20 | }
21 | return;
22 | }
23 | callback('Http Error. Status:'+x.status,null);
24 | };
25 |
26 | try {
27 | x.open('POST', 'js', true);
28 | x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
29 | if (Object.prototype.toString.call(code) === '[object Array]') {
30 | for (var i=0;i
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | nudge4j - remote console
14 |
15 |
16 |
17 |
18 |
19 |
Remote Console
20 |
23 |
// Type any code here to execute on your JVM
24 | // Here is a classic example to check the memory
25 | java.lang.management.ManagementFactory.getMemoryMXBean().getHeapMemoryUsage()
26 |
Execute
27 |
Execute (with laserbeam.js)
28 |
The output of the JVM goes here
29 |
30 |
31 |
32 |
33 |
34 |
35 |
108 |
109 |
--------------------------------------------------------------------------------
/docs/localhost.port.0.5.0/remote.console.js:
--------------------------------------------------------------------------------
1 | function togglePM(src) {
2 | var x = src.nextElementSibling;
3 | if (src.innerHTML == '+') {
4 | src.innerHTML = '-';
5 | x.style.display = 'block';
6 | }
7 | else {
8 | src.innerHTML = '+';
9 | x.style.display = 'none';
10 | return;
11 | }
12 | }
13 |
14 | function modifiersToString(mod) {
15 | var str = '';
16 | if (mod & 1) str='public ';
17 | if (mod & 2) str='private ';
18 | if (mod & 4) str='protected ';
19 | if (mod & 8) str+='static ';
20 | if (mod & 16) str+='final ';
21 | if (mod &128) str+='transient ';
22 | if (mod & 64) str+='volatile ';
23 | return str;
24 | }
25 |
26 | function render(oj) {
27 | if (oj.lines == null) {
28 | // it's a leaf.
29 | return ''+oj
30 | }
31 | var str ='';
32 | str+= 'class '+oj.name+'@'+oj.hash + '{';
33 | str+='';
34 | for (var i=0;i
+';
38 | } else {
39 | str+=' ';
40 | }
41 |
42 |
43 | if (ln.type == 'String') {
44 | str+=modifiersToString(ln.modifiers)+ln.type+' '+ln.name+' = '+JSON.stringify(ln.str)+';';
45 | } else {
46 | str+=modifiersToString(ln.modifiers)+ln.type+' '+ln.name+' = '+ln.str+';';
47 | }
48 |
49 | str+='\n';
50 | if (ln.val) {
51 | str+='';
52 | str+= render(ln.val);
53 | str+='
'
54 | } else if (ln.arr) {
55 | str+='{\n';
56 | for (var j=0;j
+'+ln.arr[j].name+'@'+ln.arr[j].hash;
64 | str+='';
65 | str+= render(ln.arr[j]);
66 | str+='
'
67 | }
68 |
69 | str+=',\n';
70 | }
71 | str+='}; '
72 | }
73 | }
74 | str+=' '
75 | str+='}';
76 | return str;
77 | }
78 |
79 |
80 |
81 |
82 |
83 | function expandAll() {
84 | var arrayOfTogglePMs = [].slice.call(document.getElementsByClassName('PlusMinus'));
85 | for (var i=0;i code {
192 | border-radius: 0;
193 | display: block;
194 | padding: 1rem 1.5rem;
195 | white-space: pre;
196 | }
197 |
198 | hr {
199 | border: 0;
200 | border-top: 0.1rem solid #f4f5f6;
201 | margin: 3.0rem 0;
202 | }
203 |
204 | input[type='email'],
205 | input[type='number'],
206 | input[type='password'],
207 | input[type='search'],
208 | input[type='tel'],
209 | input[type='text'],
210 | input[type='url'],
211 | input[type='color'],
212 | input[type='date'],
213 | input[type='month'],
214 | input[type='week'],
215 | input[type='datetime'],
216 | input[type='datetime-local'],
217 | input:not([type]),
218 | textarea,
219 | select {
220 | -webkit-appearance: none;
221 | -moz-appearance: none;
222 | appearance: none;
223 | background-color: transparent;
224 | border: 0.1rem solid #d1d1d1;
225 | border-radius: .4rem;
226 | box-shadow: none;
227 | box-sizing: inherit;
228 | height: 3.8rem;
229 | padding: .6rem 1.0rem;
230 | width: 100%;
231 | }
232 |
233 | input[type='email']:focus,
234 | input[type='number']:focus,
235 | input[type='password']:focus,
236 | input[type='search']:focus,
237 | input[type='tel']:focus,
238 | input[type='text']:focus,
239 | input[type='url']:focus,
240 | input[type='color']:focus,
241 | input[type='date']:focus,
242 | input[type='month']:focus,
243 | input[type='week']:focus,
244 | input[type='datetime']:focus,
245 | input[type='datetime-local']:focus,
246 | input:not([type]):focus,
247 | textarea:focus,
248 | select:focus {
249 | border-color: #428bca;
250 | outline: 0;
251 | }
252 |
253 | select {
254 | background: url('data:image/svg+xml;utf8, ') center right no-repeat;
255 | padding-right: 3.0rem;
256 | }
257 |
258 | select:focus {
259 | background-image: url('data:image/svg+xml;utf8, ');
260 | }
261 |
262 | textarea {
263 | min-height: 6.5rem;
264 | }
265 |
266 | label,
267 | legend {
268 | display: block;
269 | font-size: 1.6rem;
270 | font-weight: 700;
271 | margin-bottom: .5rem;
272 | }
273 |
274 | fieldset {
275 | border-width: 0;
276 | padding: 0;
277 | }
278 |
279 | input[type='checkbox'],
280 | input[type='radio'] {
281 | display: inline;
282 | }
283 |
284 | .label-inline {
285 | display: inline-block;
286 | font-weight: normal;
287 | margin-left: .5rem;
288 | }
289 |
290 | .container {
291 | margin: 0 auto;
292 | max-width: 112.0rem;
293 | padding: 0 2.0rem;
294 | position: relative;
295 | width: 100%;
296 | }
297 |
298 | .row {
299 | display: flex;
300 | flex-direction: column;
301 | padding: 0;
302 | width: 100%;
303 | }
304 |
305 | .row.row-no-padding {
306 | padding: 0;
307 | }
308 |
309 | .row.row-no-padding > .column {
310 | padding: 0;
311 | }
312 |
313 | .row.row-wrap {
314 | flex-wrap: wrap;
315 | }
316 |
317 | .row.row-top {
318 | align-items: flex-start;
319 | }
320 |
321 | .row.row-bottom {
322 | align-items: flex-end;
323 | }
324 |
325 | .row.row-center {
326 | align-items: center;
327 | }
328 |
329 | .row.row-stretch {
330 | align-items: stretch;
331 | }
332 |
333 | .row.row-baseline {
334 | align-items: baseline;
335 | }
336 |
337 | .row .column {
338 | display: block;
339 | flex: 1 1 auto;
340 | margin-left: 0;
341 | max-width: 100%;
342 | width: 100%;
343 | }
344 |
345 | .row .column.column-offset-10 {
346 | margin-left: 10%;
347 | }
348 |
349 | .row .column.column-offset-20 {
350 | margin-left: 20%;
351 | }
352 |
353 | .row .column.column-offset-25 {
354 | margin-left: 25%;
355 | }
356 |
357 | .row .column.column-offset-33, .row .column.column-offset-34 {
358 | margin-left: 33.3333%;
359 | }
360 |
361 | .row .column.column-offset-50 {
362 | margin-left: 50%;
363 | }
364 |
365 | .row .column.column-offset-66, .row .column.column-offset-67 {
366 | margin-left: 66.6666%;
367 | }
368 |
369 | .row .column.column-offset-75 {
370 | margin-left: 75%;
371 | }
372 |
373 | .row .column.column-offset-80 {
374 | margin-left: 80%;
375 | }
376 |
377 | .row .column.column-offset-90 {
378 | margin-left: 90%;
379 | }
380 |
381 | .row .column.column-10 {
382 | flex: 0 0 10%;
383 | max-width: 10%;
384 | }
385 |
386 | .row .column.column-20 {
387 | flex: 0 0 20%;
388 | max-width: 20%;
389 | }
390 |
391 | .row .column.column-25 {
392 | flex: 0 0 25%;
393 | max-width: 25%;
394 | }
395 |
396 | .row .column.column-33, .row .column.column-34 {
397 | flex: 0 0 33.3333%;
398 | max-width: 33.3333%;
399 | }
400 |
401 | .row .column.column-40 {
402 | flex: 0 0 40%;
403 | max-width: 40%;
404 | }
405 |
406 | .row .column.column-50 {
407 | flex: 0 0 50%;
408 | max-width: 50%;
409 | }
410 |
411 | .row .column.column-60 {
412 | flex: 0 0 60%;
413 | max-width: 60%;
414 | }
415 |
416 | .row .column.column-66, .row .column.column-67 {
417 | flex: 0 0 66.6666%;
418 | max-width: 66.6666%;
419 | }
420 |
421 | .row .column.column-75 {
422 | flex: 0 0 75%;
423 | max-width: 75%;
424 | }
425 |
426 | .row .column.column-80 {
427 | flex: 0 0 80%;
428 | max-width: 80%;
429 | }
430 |
431 | .row .column.column-90 {
432 | flex: 0 0 90%;
433 | max-width: 90%;
434 | }
435 |
436 | .row .column .column-top {
437 | align-self: flex-start;
438 | }
439 |
440 | .row .column .column-bottom {
441 | align-self: flex-end;
442 | }
443 |
444 | .row .column .column-center {
445 | -ms-grid-row-align: center;
446 | align-self: center;
447 | }
448 |
449 | @media (min-width: 40rem) {
450 | .row {
451 | flex-direction: row;
452 | margin-left: -1.0rem;
453 | width: calc(100% + 2.0rem);
454 | }
455 | .row .column {
456 | margin-bottom: inherit;
457 | padding: 0 1.0rem;
458 | }
459 | }
460 |
461 | a {
462 | color: #428bca;
463 | text-decoration: none;
464 | }
465 |
466 | a:focus, a:hover {
467 | color: #2a6496;;
468 | }
469 |
470 | dl,
471 | ol,
472 | ul {
473 | list-style: none;
474 | margin-top: 0;
475 | padding-left: 0;
476 | }
477 |
478 | dl dl,
479 | dl ol,
480 | dl ul,
481 | ol dl,
482 | ol ol,
483 | ol ul,
484 | ul dl,
485 | ul ol,
486 | ul ul {
487 | font-size: 90%;
488 | margin: 1.5rem 0 1.5rem 3.0rem;
489 | }
490 |
491 | ol {
492 | list-style: decimal inside;
493 | }
494 |
495 | ul {
496 | list-style: circle inside;
497 | }
498 |
499 | .button,
500 | button,
501 | dd,
502 | dt,
503 | li {
504 | margin-bottom: 1.0rem;
505 | }
506 |
507 | fieldset,
508 | input,
509 | select,
510 | textarea {
511 | margin-bottom: 1.5rem;
512 | }
513 |
514 | blockquote,
515 | dl,
516 | figure,
517 | form,
518 | ol,
519 | p,
520 | pre,
521 | table,
522 | ul {
523 | margin-bottom: 2.5rem;
524 | }
525 |
526 | table {
527 | border-spacing: 0;
528 | width: 100%;
529 | }
530 |
531 | td,
532 | th {
533 | border-bottom: 0.1rem solid #e1e1e1;
534 | padding: 1.2rem 1.5rem;
535 | text-align: left;
536 | }
537 |
538 | td:first-child,
539 | th:first-child {
540 | padding-left: 0;
541 | }
542 |
543 | td:last-child,
544 | th:last-child {
545 | padding-right: 0;
546 | }
547 |
548 | b,
549 | strong {
550 | font-weight: bold;
551 | }
552 |
553 | p {
554 | margin-top: 0;
555 | }
556 |
557 | h1,
558 | h2,
559 | h3,
560 | h4,
561 | h5,
562 | h6 {
563 | font-weight: 300;
564 | letter-spacing: -.1rem;
565 | margin-bottom: 2.0rem;
566 | margin-top: 0;
567 | }
568 |
569 | h1 {
570 | font-size: 4.6rem;
571 | line-height: 1.2;
572 | }
573 |
574 | h2 {
575 | font-size: 3.6rem;
576 | line-height: 1.25;
577 | }
578 |
579 | h3 {
580 | font-size: 2.8rem;
581 | line-height: 1.3;
582 | }
583 |
584 | h4 {
585 | font-size: 2.2rem;
586 | letter-spacing: -.08rem;
587 | line-height: 1.35;
588 | }
589 |
590 | h5 {
591 | font-size: 1.8rem;
592 | letter-spacing: -.05rem;
593 | line-height: 1.5;
594 | }
595 |
596 | h6 {
597 | font-size: 1.6rem;
598 | letter-spacing: 0;
599 | line-height: 1.4;
600 | }
601 |
602 | img {
603 | max-width: 100%;
604 | }
605 |
606 | .clearfix:after {
607 | clear: both;
608 | content: ' ';
609 | display: table;
610 | }
611 |
612 | .float-left {
613 | float: left;
614 | }
615 |
616 | .float-right {
617 | float: right;
618 | }
--------------------------------------------------------------------------------
/docs/n4j.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lorenzoongithub/nudge4j/c65ee69943097756cf07a336e8ebae1fe923a21a/docs/n4j.png
--------------------------------------------------------------------------------
/docs/twigs/dump.all.classes.js:
--------------------------------------------------------------------------------
1 | //
2 | // Inspired by this gist:
3 | // https://gist.github.com/sundararajana/f01c3edd941c1af99e0c/216c9c92e349f13a0478f96d65dd67df6ed2c9b8
4 | //
5 | function dumpAllClasses(options) {
6 | var EnumSet = java.util.EnumSet;
7 | var JavaFileObject = javax.tools.JavaFileObject;
8 | var ToolProvider = javax.tools.ToolProvider;
9 | var DiagnosticCollector = javax.tools.DiagnosticCollector;
10 | var StandardLocation = javax.tools.StandardLocation;
11 |
12 | var compiler = ToolProvider.getSystemJavaCompiler();
13 | var fm = compiler.getStandardFileManager(new DiagnosticCollector(), null, null);
14 | var kinds = EnumSet.of(JavaFileObject.Kind.CLASS);
15 | var itr = fm.list(StandardLocation.PLATFORM_CLASS_PATH, '', kinds, true).iterator();
16 | var sb = new java.lang.StringBuilder();
17 | var count = 0;
18 | while(itr.hasNext()) {
19 | var jfo = itr.next();
20 | var uri = jfo.toUri();
21 | if (uri.getScheme().equals("jar")) {
22 | var schemeSpecPart = uri.getSchemeSpecificPart();
23 | if (options && options.skipJDK &&
24 | schemeSpecPart.contains("/jre/lib/") ||
25 | schemeSpecPart.contains("/rt.jar/")) {
26 | continue;
27 | }
28 | }
29 | var name = fm.inferBinaryName(StandardLocation.PLATFORM_CLASS_PATH, jfo);
30 | if (name.contains('$')) continue; // skip inner classes.
31 | count++;
32 | sb.append( name +"\n" );
33 | }
34 | return '[Total:'+count+']\n'+sb.toString();
35 | }
--------------------------------------------------------------------------------
/docs/twigs/get.JVM.info.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var ManagementFactory = java.lang.management.ManagementFactory;
3 | var compilationMXBean = ManagementFactory.getCompilationMXBean();
4 | var runtimeMXBean = ManagementFactory.getRuntimeMXBean();
5 | var operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
6 |
7 | var info = {
8 | os : {
9 | name : operatingSystemMXBean.getName(),
10 | arch : operatingSystemMXBean.getArch(),
11 | version : operatingSystemMXBean.getVersion(),
12 | availableProcessors: operatingSystemMXBean.getAvailableProcessors(),
13 | systemLoadAverage: operatingSystemMXBean.getSystemLoadAverage()
14 | },
15 | compilation : {
16 | name : compilationMXBean.getName(),
17 | totalCompilationTimeInMS : compilationMXBean.isCompilationTimeMonitoringSupported() ? compilationMXBean.getTotalCompilationTime() : -1
18 | },
19 | runtime : {
20 | bootClassPath : runtimeMXBean.isBootClassPathSupported() ? runtimeMXBean.getBootClassPath() : null,
21 | classPath : runtimeMXBean.getClassPath(),
22 | libraryPath : runtimeMXBean.getLibraryPath(),
23 | // inputArgs
24 | managementSpecVersion : runtimeMXBean.getManagementSpecVersion(),
25 | name : runtimeMXBean.getName(),
26 | specName : runtimeMXBean.getSpecName(),
27 | specVendor : runtimeMXBean.getSpecVendor(),
28 | specVersion : runtimeMXBean.getSpecVersion(),
29 | startTime : runtimeMXBean.getStartTime(),
30 | uptime : runtimeMXBean.getUptime(),
31 | vmName : runtimeMXBean.getVmName(),
32 | vmVendor : runtimeMXBean.getVmVendor(),
33 | vmVersion : runtimeMXBean.getVmVersion(),
34 | }
35 | };
36 |
37 | var name = ManagementFactory.getRuntimeMXBean().getName();
38 | var json = JSON.stringify(info, null, 2);
39 | return json;
40 | })();
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/docs/twigs/get.class.path.js:
--------------------------------------------------------------------------------
1 | //
2 | //Returns something like:
3 | //[
4 | // { ref: "c:\temp\test.jar", classes: [], warn: "MISSING FILE" },
5 | // { ref: "c:\temp\test2.jar", classes: [ "com/test/Main", "com/test/UI" , ... ] },
6 | // { ref: "c:\temp\test2.jar", classes: [], warn: "DUPLICATE OCCURRENCE" }
7 | //]
8 | //
9 | (function() {
10 | function toClassPathArray() {
11 | var classpath = java.lang.System.getProperty("java.class.path");
12 | return classpath.split(java.lang.System.getProperty("path.separator"));
13 | }
14 |
15 | //given a reference to a jar file, we traverse the jar and return the total number of classes in the jar
16 | //and the list of packages.
17 | function countClassesAndPackages(strFile) {
18 | var file = new java.io.File(strFile);
19 | if (file.exists() == false) {
20 | return -1;
21 | }
22 | var jarFile = new java.util.jar.JarFile(file);
23 | var entries = jarFile.entries();
24 | var count = 0;
25 | var set = {};
26 | while (entries.hasMoreElements()) {
27 | var entry = entries.nextElement();
28 | if (entry.getSize() != 0) {
29 | var name = entry.getName();
30 | if (name.endsWith(".class")) {
31 | if (name.lastIndexOf("$") == -1) {
32 | // exclude innerclasses. (lazy approach)
33 | var pkg = name.substring(0, name.lastIndexOf("/"));
34 | set[pkg] = 1;
35 | count++;
36 | }
37 | }
38 | }
39 | }
40 | jarFile.close();
41 |
42 | var pkgs = [];
43 | for (var i in set) {
44 | pkgs.push(i);
45 | }
46 |
47 | return {
48 | count: count,
49 | pkgs: pkgs
50 | };
51 | }
52 |
53 | var dupList = {};
54 | var response = [];
55 | var array = toClassPathArray();
56 | for (var i = 0; i < array.length; i++) {
57 | if (array[i].endsWith(".jar")) {
58 | if (dupList[array[i]]) {
59 | response.push({
60 | ref: array[i],
61 | count: -2
62 | });
63 | } else {
64 | dupList[array[i]] = 1;
65 |
66 | var oj = countClassesAndPackages(array[i]);
67 |
68 | if (oj == -1) {
69 | response.push({
70 | ref: array[i],
71 | count: -1
72 | });
73 | } else {
74 | response.push({
75 | ref: array[i],
76 | count: oj.count,
77 | pkgs: oj.pkgs
78 | });
79 | }
80 | }
81 | }
82 | }
83 | var json = JSON.stringify(response, null, 2);
84 | return json;
85 | })();
--------------------------------------------------------------------------------
/docs/twigs/get.thread.dump.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var map = java.lang.Thread.getAllStackTraces();
3 | var threads = map.keySet().toArray();
4 | var array = [];
5 | for (var i = 0; i < threads.length; i++) {
6 | var t = threads[i];
7 | var stackArray = map.get(t);
8 | var stackJSArray = [];
9 | for (var j = 0; j < stackArray.length; j++) {
10 | var stk = stackArray[j];
11 | stackJSArray.push({
12 | stackElement: stk + ""
13 | });
14 | }
15 | array.push({
16 | id: t.getId(),
17 | name: t.getName() + "",
18 | priority: t.getPriority(),
19 | state: t.getState() + "",
20 | stackArray: stackJSArray
21 | });
22 | }
23 |
24 | var oj = {
25 | time: java.lang.System.currentTimeMillis(),
26 | dump: array
27 | };
28 |
29 | var json = JSON.stringify(oj, null, 2);
30 | return json;
31 | })();
32 |
--------------------------------------------------------------------------------
/docs/twigs/get.thread.x.cpu.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var tmxb = java.lang.management.ManagementFactory.getThreadMXBean();
3 | var threadIDs = tmxb.getAllThreadIds();
4 | var array = [];
5 | var totalCPUTime = 0;
6 | for (var i=0;i 0 && f.getModifiers() & 8) { continue; } // Skip static fields for any non-root level.
77 | f.setAccessible(true);
78 |
79 | (function(xoj, level) {
80 | var str = stringifyIfPristine(xoj);
81 | if (str !== null) {
82 | output.lines.push({
83 | modifiers : f.getModifiers(),
84 | type : typeToString( f.getType() ),
85 | name : f.getName(),
86 | str : str });
87 | return;
88 | }
89 |
90 | var clz = xoj.getClass();
91 |
92 | if (clz.isArray()) {
93 | var componentType = clz.getComponentType();
94 |
95 | // change this to 2 and JPanel breaks (unless I am filtering out static) :-(
96 | if (level > 1) {
97 | output.lines.push({
98 | modifiers : f.getModifiers(),
99 | type : typeToString( f.getType() ),
100 | name : f.getName(),
101 | str : clz.getName() + "@" + _toHexString(xoj.hashCode()) });
102 | return;
103 | }
104 | var len = java.lang.reflect.Array.getLength(xoj);
105 | var array = [];
106 | for (var i=0;i 2) ? undefined : explore(xoj,level+1) });
124 | })(f.get(oj), level);
125 |
126 |
127 | f.setAccessible(false);
128 | }
129 | clz = clz.getSuperclass();
130 | }
131 | return output;
132 | }
133 |
134 | return function(oj) {
135 | return JSON.stringify(explore(oj),null,2);
136 | };
137 | })();
138 |
--------------------------------------------------------------------------------
/docs/twigs/n4j.boot.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var System = Java.type("java.lang.System");
3 |
4 | if (System.getProperty("nudge4j.start")) {
5 | System.err.println("[Warning] Attempt to start nj again. Ignoring the request.");
6 | return;
7 | }
8 | System.setProperty("nudge4j.start", System.currentTimeMillis());
9 |
10 | var array = java.lang.Thread.currentThread().getStackTrace();
11 | for (var i=1;i