+ 2

Memory limit exceeded error on Sololearn.

On Sololearn, I noticed that some of my codes could work on an IDE, but, when I run it on Sololearn, I get a "Memory limit exceeded" error, and my code doesn't compile. Such as this code here: import javax.script.ScriptException; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import java.util.Scanner; /*Only works in an IDE - Memory Limit is exceeded if used in Sololearn.*/ public class Calc { public static void main(String[] args) throws ScriptException { Scanner scan = new Scanner(System.in); while(scan.hasNext()){ ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine engine = mgr.getEngineByName("JavaScript"); try{ String equa = scan.next(); if(equa.equalsIgnoreCase("end")){ System.out.println("End."); break; } System.out.println(engine.eval(equa)); }catch (Exception e){ System.out.println("ERROR! Bad input."); } } } } Why does this happen?

10th Apr 2018, 12:02 AM
Sheldon Duncan
Sheldon Duncan - avatar
1 Odpowiedź
+ 5
I'd be very surprised to learn SoloLearn supported javax.script.*. They seem to only support a small subset of libraries.
10th Apr 2018, 12:52 AM
John Wells
John Wells - avatar