473,327 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Error in Running Converted JavaClass File From Java Script(Hello World Application)

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.but its runnig with no error and not getting the out put.This is the converted java class for printing "HelloWorld".

Expand|Select|Wrap|Line Numbers
  1. import org.mozilla.javascript.*;
  2. import org.mozilla.javascript.optimizer.OptRuntime;
  3.  
  4. public class Hello extends NativeFunction
  5. implements Script
  6. {
  7.  
  8. private int _id;
  9. private Hello _dcp;
  10. private Object _re[];
  11.  
  12. public Hello()
  13. {
  14. _id = 0;
  15. }
  16.  
  17. public static void main(String args[])
  18. {
  19. OptRuntime.main(new Hello(), args);
  20. }
  21.  
  22. public final Object exec(Context context, Scriptable scriptable)
  23. {
  24. return call(context, scriptable, scriptable, null);
  25. }
  26.  
  27. public final Object call(Context context, Scriptable scriptable, Scriptable scriptable1, Object aobj[])
  28. {
  29. if(!ScriptRuntime.hasTopCall(context))
  30. {
  31. return ScriptRuntime.doTopCall(this, context, scriptable, scriptable1, aobj);
  32. } else
  33. {
  34. return _c0(this, context, scriptable, scriptable1, aobj);
  35. }
  36. }
  37.  
  38. public int getLanguageVersion()
  39. {
  40. return 0;
  41. }
  42.  
  43. public String getFunctionName()
  44. {
  45. return "";
  46. }
  47.  
  48. public int getParamCount()
  49. {
  50. return 0;
  51. }
  52.  
  53. public int getParamAndVarCount()
  54. {
  55. return 0;
  56. }
  57.  
  58. public String getParamOrVarName(int i)
  59. {
  60. return null;
  61. }
  62.  
  63. public String getEncodedSource()
  64. {
  65. return "\207'^<html>\n<body>\n<script type=\"text/javascript\">\nalert(\"Hello World!\")" +
  66. ";\n</script>\n</body>\n</html>Q\001"
  67. .substring(0, 99);
  68. }
  69.  
  70. public boolean getParamOrVarConst(int i)
  71. {
  72. return false;
  73. }
  74.  
  75. private static Object _c0(Hello hello, Context context, Scriptable scriptable, Scriptable scriptable1, Object aobj[])
  76. {
  77. ScriptRuntime.initScript(hello, scriptable1, context, scriptable, false);
  78. Object obj = Undefined.instance;
  79. obj = ScriptRuntime.newObject(ScriptRuntime.name(context, scriptable, "XML"), context, scriptable, new Object[] {
  80. "<html>\n<body>\n<script type=\"text/javascript\">\nalert(\"Hello World!\");\n</s" +
  81. "cript>\n</body>\n</html>"
  82.  
  83. });
  84. return obj;
  85. }
  86. }
  87.  
Apr 9 '09 #1
0 2551

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Charles Handy | last post by:
How does FastCGI compare against java Apps running in java app servers like TomCat, Sun One, WebLogic and WebSphere? Is there a business case for switching from CGI to Java? Performance?...
2
by: Begoña | last post by:
in my java application I've made a call to this stored procedure CREATE procedure pruebaICM @pANI varchar(20), @pTABLA varchar(20), @pInsert varchar(500), @pUpdate varchar(1000), @pFLAG...
1
by: sandyde2 | last post by:
Hi all, I am writing a java application as a mozilla extension. Because mozilla uses javascript for the frontend, i need the javascript to call my external java application and pass one...
4
by: sai | last post by:
Hi.. Thanks to all I am a fresher want to build my carrier in programming field .. please give me u r valuable suggisition .. that.. how can i build my career in java world?
3
by: Gary Wessle | last post by:
thanks for helping with this problem I am getting errors starting with fred@debian:~/myPrograms/cpp/practice$ make cc hello.cpp /tmp/ccQzQfGH.o: In function `main': hello.cpp:(.text+0x27):...
2
Saghar
by: Saghar | last post by:
Hi, Could somebody help me about this topic? I want to know how we can call and execute a non-java source file in a java application. For example, a simple Java application is run, there is an...
21
by: ding | last post by:
I am facing problem to writting file to MySQL database in java application. Can show me a example code? Thanks!
8
by: Ananthu | last post by:
Hi I have done all the codings part for connecting mysql with java in eclipse environment. Coding Part: import java.sql.Connection; import java.sql.DriverManager; public class...
1
by: tinmaung | last post by:
hi please help me i want to know how to play sound in java application i don't mean java applet if you can, please send me how to write coding to play sound in application.
2
by: babp | last post by:
Hi Iam new to perl and need a help to send inputs to an running application : I am running an application XXXX , and when it starts i am passing a file name called "connect.spb" and after the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.