Forum Stats

  • 3,873,819 Users
  • 2,266,677 Discussions


Why a java script works fine in rhino engine in java1.6, but not in nashorn script engine in java1.8

Solomon Mohanty
Solomon Mohanty Member Posts: 2
edited Jul 12, 2016 10:04PM in JavaScript - Nashorn

A java script to load java classes from a http server by a custom class loader works fine in jre1.6 with rhino engine. But same script doesn't

work in nashorn engine in jre1.8. Exception thrown is access denied ("" "" "connect,resolve"

I tried using below URL to give all permission for java and script code to have all permissions.

Code is similar to below lines:

"var tmp = UcmdbServiceFactory.initSSL();" +

  "var serviceProvider = UcmdbServiceFactory.getServiceProvider(\"https\",\"\",8443); " +

  "var clientContext = serviceProvider.createClientContext(\"UCSD\"); " ;

     ScriptEngineManager m = new ScriptEngineManager();

      ScriptEngine engine = m.getEngineByName("nashorn");

  File file = new File(args[0]);

        try {


        URI uri = file.toURI();

        URL url = uri.toURL();

        engine.eval(new URLReader(url));

If anybody has any experience with network class loaders using nashorn script engine, help here.