-
Install JDK 14
-
Install Python 2
-
Use
nodev6.17.1(ts-javawon't build on later versions) -
Add this to
package.json:{ "scripts": { "preinstall": "npm run npm-force-resolutions", "npm-force-resolutions": "npm-force-resolutions" }, "resolutions": { "java": "github:joeferner/node-java#master", "find-java-home": "1.1.0" } } -
Remove
node_modulesandpackage-lock.json(just in case) -
Run
npm i npm --saveto upgrade tonpmwhich understandspackage-lock.json -
Run
npm i --ignore-scriptsto generatepackage-lock.json -
Remove
node_modules/javaandnode_modules/ts-java(to force reinstallation and re-running of build scripts) -
Run
npm i --python=C:\Python27\python.exe -
In
node_modules\ts-java\lib\ts-java-main.jsremoveclasspath.push(rtJarPath);line. Instead, we'll download and add it topackage.json. Make sure that it's a full and not stripped down version, use archive manager to look inside of jar, there should be a lot of folders. Or, grab one from this repo.{ "ts-java": { "classpath": "rt.jar" } } -
Run
node node_modules\ts-java\bin\ts-java.jsand don't wait, go to the next step -
Don't wait for
ts-java.jsto finish, it will never finish for some reason. Instead, look fortsJavaModule.tsfile to be created or updated. Once it's there - terminate script. -
???
-
Profit!
-
See
usagefolder -
Make sure to replace
var fullJarPath: string = path.join(__dirname, "", jarPath); _java.classpath.push(fullJarPath);
with
_java.classpath.push(jarPath);
in case if you're using absolute paths to your
jars. -
Don't forget to switch back to the latest NodeJS version (tested on
v14.7.0) since we don't have to deal with outdatedts-javasources anymore -
Install deps from
package.json -
Run
npx ts-node .\index.ts