We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all, I would like to asking if is possible execute a node js script using processing?. if so, how can I do this?. I have tried to do it but I have not succeeded. thanks
I don't believe so. However, Java got a built-in JS called Nashorn: https://forum.Processing.org/two/discussions/tagged?Tag=#nashorn
What kind of script; what is it for? There might be other ways of accomplishing whatever you are trying to do....
http://blog.JonasBandi.net/2014/03/running-nodejs-applications-on-jvm-with.html
https://Avatar.java.net/
Hi all, sorry for reply so late but I was busy. I solve my ploblem, it was more easy than I was thinking. Below you can see the solution::
import java.io.IOException; import org.apache.commons.exec.CommandLine; import org.apache.commons.exec.DefaultExecutor; import org.apache.commons.exec.ExecuteException; public class TestScript { int iExitValue; String sCommandString; public void runScript(String command){ sCommandString = command; CommandLine oCmdLine = CommandLine.parse(sCommandString); DefaultExecutor oDefaultExecutor = new DefaultExecutor(); oDefaultExecutor.setExitValue(0); try { iExitValue = oDefaultExecutor.execute(oCmdLine); } catch (ExecuteException e) { System.err.println("Execution failed."); e.printStackTrace(); } catch (IOException e) { System.err.println("permission denied."); e.printStackTrace(); } } public void initScript(){ TestScript testScript = new TestScript(); testScript.runScript("node scrip.js"); } }
The nex step is ass the jar file "org.apache.commons.exec", to do this, go to "Sketch ---> Add File ---> org.apache.commons.exec" and thas it.
Thanks for your help.
@jarain78 -- thank you for sharing your solution with the community!
Answers
I don't believe so. However, Java got a built-in JS called Nashorn:
https://forum.Processing.org/two/discussions/tagged?Tag=#nashorn
What kind of script; what is it for? There might be other ways of accomplishing whatever you are trying to do....
http://blog.JonasBandi.net/2014/03/running-nodejs-applications-on-jvm-with.html
https://Avatar.java.net/
Hi all, sorry for reply so late but I was busy. I solve my ploblem, it was more easy than I was thinking. Below you can see the solution::
The nex step is ass the jar file "org.apache.commons.exec", to do this, go to "Sketch ---> Add File ---> org.apache.commons.exec" and thas it.
Thanks for your help.
@jarain78 -- thank you for sharing your solution with the community!