Hi,
My first problem was i am not able to compiled a file from java script to java class.Now its clear and working fine..now i can convert a java script file to java class by Rhino Java Script Compiler.But now i am facing 1 more problem.i want to run that java class in IntelliJIdea.bu t its runnig with no error and not getting the out put.This is the converted java class for printing "HelloWorld ".
My first problem was i am not able to compiled a file from java script to java class.Now its clear and working fine..now i can convert a java script file to java class by Rhino Java Script Compiler.But now i am facing 1 more problem.i want to run that java class in IntelliJIdea.bu t its runnig with no error and not getting the out put.This is the converted java class for printing "HelloWorld ".
Code:
import org.mozilla.javascript.*; import org.mozilla.javascript.optimizer.OptRuntime; public class Hello extends NativeFunction implements Script { private int _id; private Hello _dcp; private Object _re[]; public Hello() { _id = 0; } public static void main(String args[]) { OptRuntime.main(new Hello(), args); } public final Object exec(Context context, Scriptable scriptable) { return call(context, scriptable, scriptable, null); } public final Object call(Context context, Scriptable scriptable, Scriptable scriptable1, Object aobj[]) { if(!ScriptRuntime.hasTopCall(context)) { return ScriptRuntime.doTopCall(this, context, scriptable, scriptable1, aobj); } else { return _c0(this, context, scriptable, scriptable1, aobj); } } public int getLanguageVersion() { return 0; } public String getFunctionName() { return ""; } public int getParamCount() { return 0; } public int getParamAndVarCount() { return 0; } public String getParamOrVarName(int i) { return null; } public String getEncodedSource() { return "\207'^<html>\n<body>\n<script type=\"text/javascript\">\nalert(\"Hello World!\")" + ";\n</script>\n</body>\n</html>Q\001" .substring(0, 99); } public boolean getParamOrVarConst(int i) { return false; } private static Object _c0(Hello hello, Context context, Scriptable scriptable, Scriptable scriptable1, Object aobj[]) { ScriptRuntime.initScript(hello, scriptable1, context, scriptable, false); Object obj = Undefined.instance; obj = ScriptRuntime.newObject(ScriptRuntime.name(context, scriptable, "XML"), context, scriptable, new Object[] { "<html>\n<body>\n<script type=\"text/javascript\">\nalert(\"Hello World!\");\n</s" + "cript>\n</body>\n</html>" }); return obj; } }