Java execution JavaScript and container-session issues

Source: Internet
Author: User

1. Option A. JDK 6 starts with the built-in Rhino engine B. jdk8 replacement Nashorn (high performance, better for ECMA Support) C. Java version of Nodejs Vertx.io 2. Practical operation
public static void Main (string[] args) {Scriptenginemanager manager = new Scriptenginemanager ();        ScriptEngine engine = Manager.getenginebyname ("Nashorn");            try {int value=2;            Simplebindings bind=new simplebindings ();            Simplebindings bind2=new simplebindings ();            Simplebindings bind3=new simplebindings ();            Bind.put ("Points", value);            Bind2.put ("A", value);            Bind2.put ("B", value);            Bind3.put ("A1", value+1);             Bind3.put ("B1", value+2);            System.out.println (Engine.eval ("Points <50?50:math.ceil (56/50) *50", bind)); System.out.println (Engine.eval ("Demosum=function (A, b) {return a+b};    Demosum (A, b); ", Bind2)); Defines the method and invokes the support parameter binding System.out.println (Engine.eval (function (A1,B1) {function demosub (A, b) {return a+b;}    Return Demosub (A1,B1)}) (A1,B1) ", Bind3)";        Use JS to execute function immediately} catch (Scriptexception e) {e.printstacktrace (); }    }
3. Docker container handling Docker container in practice there is a principle that the image of the container should be as small as possible general people will choose to use the Alpine Linux distribution for Dockerfile as follows:
FROM frolvlad/alpine-oraclejdk8:fullVOLUME /tmpADD demo.class demo.classRUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtimeENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","app"]
Note the tag selection of the image uses the full execution result



Java execution JavaScript and container-session issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.