Home > Article > Web Front-end > How to run javascript code without using a browser_javascript tips
Sometimes we want to write a small program in js, but we find it troublesome to run it using a browser. So now let's take a look at how to use a java program to call a javascript program, so that the js code can be executed without the help of a browser. .
The reason for this requirement is because I encountered such a problem in a project I was working on these days. I have a javascript script, but the other codes of this project are all written in CC. I don’t want to use js Converting the code to C felt too troublesome, so I thought it would be great if I could directly call the javascript code under C, or there would be a tool in the shell that can directly run the js code without using a browser. Now you can use java code to call javascript code. You can write a shell script to encapsulate it and run the js code directly under the shell.
First of all, if you want to install java.
The java code is as follows: