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?
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
file = java.io.File
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.c its essentially calling globalscope[c] = a.b.c, in order to import this Java package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With