I am writing a standalone application in Java that needs to be able to call custom Javascript APIs? Is there a way to call custom Javascript APIs in Java?
+1
A:
In a browser?
If your applet exposes a scriptable interface, yes you can.
jldupont
2009-12-10 17:11:34
This looks like a good thing. Perhaps for the custom APIs, it would be good to use the Rhino Javascript Compiler. Then, use those classes in my Java code?
stjowa
2009-12-10 17:19:51
For the purposes of scripting your application, it is better to embed Rhino in your application and then interpret the scripts at run time. That would allow your users to create "macros" that control your app. Where you store the scripts doesn't matter (resource bundle, files, DB etc)If you compile your JS to java class files using the compiler, then they aren't really any different then any other Java class file, which is probably not what you want.
Mark Porter
2009-12-10 20:03:57
A:
Aside from the name, javascript and java have no relationship whatsoever.
Joel Coehoorn
2009-12-10 17:12:16
I didn't mod you down but I would guess whoever did so did it because it is not true anymore...
Fredrik
2009-12-10 17:14:22
i think i will never be able to understand why the hell on SO, do somebody downvote sensible answers as well
Rakesh Juyal
2009-12-10 17:15:27
This answer is not sensible, it is irrelevant. stjowa is clearly aware that Java and Javascript are different beasts.
Michael Borgwardt
2009-12-10 17:34:58
@Fredrik. Could you elaborate on the relationship? Surely you can use both in the same project, and things like Rhino let them interact, but as languages they are independent, and javascript is really just another name for ecmascript anyway.
Peter Recore
2009-12-10 17:36:04
A:
JSon could be your one stop. Let me know if you are looking for this?
DKSRathore
2009-12-10 17:14:10
I guess this answer assumes that the "Javascript APIs" in question are services accessible through the internet.
Michael Borgwardt
2009-12-10 17:37:45