Web Analytics Made Easy -
StatCounter Error in Running Converted JavaClass File From Java Script - CodingForum

Announcement

Collapse
No announcement yet.

Error in Running Converted JavaClass File From Java Script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error in Running Converted JavaClass File From Java Script

    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.But now i am facing 1 more problem.i want to run that java class in IntelliJIdea.but 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;
        }
    }
    Last edited by tosreejithp; Apr 9, 2009, 10:12 AM.

  • #2
    This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names.

    Please read the posting guidelines regarding the use of [code] tags. Wrapping your code in [code] tags means use the octothorpe or #symbol on the toolbar. The word CODE should be in upper case but of course if I wrote it like that here it would wrap this text in code tags. You can edit your previous post.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

    Comment


    • #3
      Actually, the [code] tag doesn't have to be upper-case... though it does need a closing tag. Which in turn I won't be using due to... well, not wanting to wrap my post as a code... I'm sure most people know how to use closing tags though, so it shouldn't be too hard to figure out.
      The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

      How to ask smart questions?

      Comment

      Working...
      X