java-caller 3.2.1-beta202311260852.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/lib/java-caller.js +6 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
[](https://www.npmjs.com/package/java-caller)
|
|
5
5
|
[](https://npmjs.org/package/java-caller)
|
|
6
|
-
[](https://npmjs.org/package/java-caller)
|
|
6
|
+
[](https://npmjs.org/package/java-caller)<!-- gh-dependents-info-used-by-start -->
|
|
7
|
+
[](https://github.com/nvuillam/node-java-caller/blob/main/docs/github-dependents-info.md)<!-- gh-dependents-info-used-by-end -->
|
|
7
8
|
[](https://circleci.com/gh/nvuillam/node-java-caller/tree/master)
|
|
8
9
|
[](https://github.com/nvuillam/mega-linter#readme)
|
|
9
10
|
[](https://codecov.io/gh/nvuillam/node-java-caller)
|
|
@@ -71,6 +72,7 @@ Example: `["-Xms256m", "--someflagwithvalue myVal", "-c"]`
|
|
|
71
72
|
| [cwd](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) | You can override cwd of spawn called by JavaCaller runner | `process.cwd()` | `some/other/cwd/folder` |
|
|
72
73
|
| javaArgs | List of arguments for JVM only, not the JAR or the class | `[]` | `['--add-opens=java.base/java.lang=ALL-UNNAMED']` |
|
|
73
74
|
| [windowsVerbatimArguments](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) | No quoting or escaping of arguments is done on Windows. Ignored on Unix. This is set to true automatically when shell is specified and is CMD. | `true` | `false` |
|
|
75
|
+
| [windowless](https://docs.oracle.com/en/java/javase/17/docs/specs/man/java.html#:~:text=main()%20method.-,javaw,information%20if%20a%20launch%20fails.) | If windowless is true, JavaCaller calls javaw instead of java to not create any windows, useful when using detached on Windows. Ignored on Unix. | false | true
|
|
74
76
|
|
|
75
77
|
## Examples
|
|
76
78
|
|
|
@@ -136,6 +138,16 @@ const { status, stdout, stderr, childJavaProcess } = await java.run(['--sleep'],
|
|
|
136
138
|
childJavaProcess.kill('SIGINT');
|
|
137
139
|
```
|
|
138
140
|
|
|
141
|
+
Call a windowless java process
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
const java = new JavaCaller({
|
|
145
|
+
classPath: 'test/java/dist',
|
|
146
|
+
mainClass: 'com.nvuillam.javacaller.JavaCallerTester'
|
|
147
|
+
});
|
|
148
|
+
const { status, stdout, stderr } = await java.run(['--sleep'], { windowless: true });
|
|
149
|
+
```
|
|
150
|
+
|
|
139
151
|
You can see **more examples in** [**test methods**](https://github.com/nvuillam/node-java-caller/blob/master/test/java-caller.test.js)
|
|
140
152
|
|
|
141
153
|
## TROUBLESHOOTING
|
package/lib/java-caller.js
CHANGED
|
@@ -24,6 +24,7 @@ class JavaCaller {
|
|
|
24
24
|
|
|
25
25
|
javaSupportDir;
|
|
26
26
|
javaExecutable = "java";
|
|
27
|
+
javaExecutableWindowless = "javaw";
|
|
27
28
|
additionalJavaArgs = [];
|
|
28
29
|
commandJavaArgs = [];
|
|
29
30
|
|
|
@@ -80,13 +81,14 @@ class JavaCaller {
|
|
|
80
81
|
runOptions.cwd = typeof runOptions.cwd === "undefined" ? process.cwd() : runOptions.cwd;
|
|
81
82
|
runOptions.stdoutEncoding = typeof runOptions.stdoutEncoding === "undefined" ? "utf8" : runOptions.stdoutEncoding;
|
|
82
83
|
runOptions.windowsVerbatimArguments = typeof runOptions.windowsVerbatimArguments === "undefined" ? true : runOptions.windowsVerbatimArguments;
|
|
84
|
+
runOptions.windowless = typeof runOptions.windowless === "undefined" ? false : os.platform() !== "win32" ? false : runOptions.windowless;
|
|
83
85
|
this.commandJavaArgs = (runOptions.javaArgs || []).concat(this.additionalJavaArgs);
|
|
84
86
|
|
|
85
|
-
let javaExe = this.javaExecutable;
|
|
87
|
+
let javaExe = runOptions.windowless ? this.javaExecutableWindowless : this.javaExecutable;
|
|
86
88
|
if (javaExe.toLowerCase().includes(".exe") && !javaExe.includes(`'`)) {
|
|
87
89
|
// Java executable has been overridden by caller : use it
|
|
88
90
|
javaExe = `"${path.resolve(javaExe)}"`;
|
|
89
|
-
} else if (javaExe === "java") {
|
|
91
|
+
} else if (javaExe === "java" || javaExe === "javaw") {
|
|
90
92
|
// Check if matching java version is present, install and update PATH if it is not
|
|
91
93
|
await this.manageJavaInstall();
|
|
92
94
|
}
|
|
@@ -102,7 +104,7 @@ class JavaCaller {
|
|
|
102
104
|
debug(`Java command: ${javaExe} ${javaArgs.join(" ")}`);
|
|
103
105
|
const spawnOptions = {
|
|
104
106
|
detached: runOptions.detached,
|
|
105
|
-
cwd: javaExe === "java" ? runOptions.cwd : undefined,
|
|
107
|
+
cwd: javaExe === "java" || javaExe === "javaw" ? runOptions.cwd : undefined,
|
|
106
108
|
env: Object.assign({}, process.env),
|
|
107
109
|
stdio: this.output === "console" ? "inherit" : runOptions.detached ? "ignore" : "pipe",
|
|
108
110
|
windowsHide: true,
|
|
@@ -426,4 +428,4 @@ class JavaCaller {
|
|
|
426
428
|
}
|
|
427
429
|
}
|
|
428
430
|
|
|
429
|
-
module.exports = { JavaCaller };
|
|
431
|
+
module.exports = { JavaCaller };
|
package/package.json
CHANGED