Hi - I have a file called, 'env-config.js' that has contents like this:

angular.module('dpsCore.configEnv', [])
  .constant('CONFIG_ENV', {
    'name': 'stage01',
    'DEV_ENV': true,
    'ENABLE_LOCALES': true
  });


I need to read/parse this file from Java 7 code - in particular, I need to 
load and store the variables (name, DEV_ENV, ENABLE_LOCALES).

I have tried some simple code using the javax.scripting library like this:
        ScriptEngineManager factory = new ScriptEngineManager();
        ScriptEngine engine = factory.getEngineByName("JavaScript");
        // 'script' = the code above
        engine.eval(script);
And I get this:
Exception in thread "main" javax.script.ScriptException: 
sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "angular" is 
not defined. (<Unknown source>#1) in <Unknown source> at line number 1
    at 
com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:224)
    at 
com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:240)
    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
    at sandbox.TestApp.main(TestApp.java:69)
Caused by: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: 
"angular" is not defined. (<Unknown source>#1)

Does anyone know how I can parse the above file?
Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to