Interpreting JavaScript in Java with Rhino: pausing/resuming scripts

前端 未结 3 1243
时光说笑
时光说笑 2020-12-30 03:44

I\'m using the javax.script.* package of the JDK. Specifically, I\'m using the JavaScript engine, which, from what I\'ve read, seems to be based on a Mozilla-developed Java

3条回答
  •  无人及你
    2020-12-30 04:21

    You didn't explain why you were doing this, but I was emulating a program that interacts with an end user, like this:

    print('Hello!'); 
    a=Number(input('enter a number')); 
    b=Number(input('and another number')); 
    print('the sum of '+a+' plus '+b+' is '+(a+b))
    

    I've got it working just by creating a print and an input function in javascript that checks for program state.

    you can see a demo here.

    it's all written in javascript so you can look at the source code with any browser.

    Hope it helps

提交回复
热议问题