node-java finishing the program

238 views
Skip to first unread message

Baubak G.

unread,
Sep 27, 2022, 3:31:59 AM9/27/22
to node-java
Hi there,

I am just discovering node-java, and I like it a lot. Thanks for this library.

I was unable to find any mention of this problem:
When using the Hello World example, it seems that node-java does not finish by itself, and I need to actively interrupt the call.

example my node file "testHelloWorkJSCallingJava.js":
```
var java = require('java');
var javaLangSystem = java.import('java.lang.System');

javaLangSystem.out.printlnSync('Hello World!');
````

When I execute it using node it wxorks fine, but it does not quit, and I have to press Ctrl+C to stop:
```
simpleJSToJava % node testHelloWorkJSCallingJava.js
Hello World!
```

Is there anything I am missing?



Mike Autry

unread,
Sep 22, 2023, 11:17:26 AM9/22/23
to node-java
I ran into this issue as well.  I am not certain of the best approach.  But, what I have done is created a function to perform house-keeping that nulls out any objects I created then at the very end of my script I just call process.exit(0);
Hope this helps someone 

Thanks,
Mike

Baubak G.

unread,
Nov 3, 2023, 10:37:31 AM11/3/23
to node-java
I actually wrote an alternative plugin that accesses Java differently. Although this solution was great, there were too many issues.


This way your Node version/cypress version relains the same, and no java objects are in your project, but you can still access them.

PS: sorry for mentioning this in this forum, but I had to move to another solution due to the different issues with python / node / java. The solution was great, and it helped me a lot.
Reply all
Reply to author
Forward
0 new messages