4

I can't for the life of me figure out how to import javascript files in javascript under Rhino. Basically, all I want to do is import "some file.js" and be able to use the things in scope there.

I've been trying to mess with Context.currenctContext (compileString and compileReader), but I don't understand how to get the appropriate Scope and I keep getting the exception "Cannot find default value for object" with this code:

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

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

B T
  • 57,525
  • 34
  • 189
  • 207
  • 2
    possible duplicate of [JavaScript (Rhino) use library or include other scripts](http://stackoverflow.com/questions/650377/javascript-rhino-use-library-or-include-other-scripts) – Nateowami Aug 04 '15 at 04:25

1 Answers1

7

JavaScript (Rhino) use library or include other scripts

Community
  • 1
  • 1
B T
  • 57,525
  • 34
  • 189
  • 207