In etherpad’s source I’ve seen code like:
jimport(java.util.Date, "JDate");
But it doesn’t seem like some kind of javascript standard.
How is it done?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Looks like you’re looking at the etherpad source. There they defined a helper function named
jimport.As mentioned, etherpad uses Rhino as its Javascript engine, which have Java available at his fingertips. So it is enough to make
in order to “import” it.
This function uses the helper function
_jimportSinglePackage, to inject the Java package into the local Javascript scope.This function receives the package name, and the global scope to which it’ll inject the package to, and given
a.b.cits essentially callingglobalscope[c] = a.b.c, in order toimportthis Java package.