Nashorn - Java 8 - Error - HELP!

Results 1 to 1 of 1
  1. #1
    Infraction Banned sadiaas is offline
    MemberRank
    Dec 2013 Join Date
    Bredsten, SondeLocation
    46Posts

    Support Nashorn - Java 8 - Error - HELP!

    This is the error im getting when i launch the server:
    Spoiler:





    And this is my code for my AbstractScriptManager:
    Spoiler:
    Code:
    package net.sf.odinms.scripting;
    
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    import javax.script.*;
    import net.sf.odinms.client.MapleClient;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import jdk.nashorn.api.scripting.NashornScriptEngine;
    
    public abstract class AbstractScriptManager {
    
    private boolean nashorn = true;    
        
    private ScriptEngineFactory sef;
    protected static final Logger log = LoggerFactory.getLogger(AbstractScriptManager.class);
    
        protected AbstractScriptManager() {
            sef = new ScriptEngineManager().getEngineByName("javascript").getFactory();
        }
    
        protected NashornScriptEngine getScriptEngine(String path) {
            path = "scripts/" + path;
            File scriptFile = new File(path);
            if (!scriptFile.exists()) {
                return null;
            }
            NashornScriptEngine engine = (NashornScriptEngine) sef.getScriptEngine();
            try (FileReader fr = new FileReader(scriptFile)) {
                if (nashorn == true){
                    engine.eval("load('nashorn:mozilla_compat.js');" + System.lineSeparator());
                }
                engine.eval(fr);
            } catch (final ScriptException | IOException t) {
                log.error("Error executing script.", t);
                return null;
            }
    
            return engine;
        }
    
        protected NashornScriptEngine getScriptEngine(String path, MapleClient c) {
            NashornScriptEngine engine = (NashornScriptEngine) c.getScriptEngine("scripts/" + path);
            if (engine == null) {
                engine = getScriptEngine(path);
                c.setScriptEngine(path, engine);
            }
    
            return engine;
        }
    
        protected void resetContext(String path, MapleClient c) {
            c.removeScriptEngine("scripts/" + path);
        }
    }


    I'm not really sure what the issue is at this point so i anyone could tell me
    - in a possibily noob friendly way :D then I'm all ears xD!

    FWI!
    I'm using XiuzSource




Advertisement