How do I take output from a java class?


#1

I my web application using Meteor framework, I have to supply an input, compute it and take output from a java class. Can I do it or I need to “translate” from java class to javascript ? Thanks


#2

Javascript and Java cannot interoperate by default. You can either try to find a javascript based alternative of your Java code, or re-code it in Javascript. If neither of these are really options, then you could look into wrapping your Java based code in a web service (so potentially create a simple servlet running in a container like Tomcat somewhere), then have your Meteor based app communicate with that Java/servlet based web service.


#3

if that’s a java executable and you have the jre installed, you can execute it and read the result on the shell

node has shell access and there are packages like shelljs that make this easy and cross platform for you

edit:
I also just found https://www.npmjs.com/package/java which looks very interesting!