How to import other rhino javascript files

I can’t understand for life how to import javascript files into javascript under Rhino. Basically, all I want to do is import "some file.js" and be able to use things in the area there.

I am trying to interact with Context.currenctContext (compileString and compileReader), but I don’t understand how to get the corresponding Scope, and I continue to get the exception β€œCan't find the default value for the object” with this code:

Context.currentContext.compileString("print('something')", "whatever, 0, null).exec(Context.currentContext, null) 

It seems pretty dumb if I can't create modules that I can then reuse in my javascript programs ... Does anyone know how to solve this?

+4
source share

Source: https://habr.com/ru/post/1340768/


All Articles