Creating your own JNEXT extensions

If you have some experience in C++ and JavaScript, it is a very simple procedure to create your own native extensions to JavaScript. To get started, you should first download the JNEXT sources and take a look at the ReadMe.html file to see what's included.

The easiest way to create a new JNEXT plugin (as with most technologies) is to modify an existing minimalistic working sample. The JNEXT sources include a sample which was created specifically to be used as a starting point to create your own extension plugin. The sample plugin source is named filereader. You might first want to test the filereader sample by opening the JS-FileReader.html file after installing the JNEXT setup. Basically what JS-FileReader.html does is simply display the content of a file on your system in a zebra striped manner on your browser.

Creating a JNEXT plugin consists of two stages. Fortunately they are both simple: In stage 1, you create the native extension. In stage 2 you create the JavaScript wrapper class for the extension created in stage 1.

Creating the native extension

The filereader project contains all the information you'll probably need to create a native extension. Basically, just follow the guidelines described in the comments of filereader.cpp and you're done.

Creating the JavaScript wrapper class

Again, just take a look at the FileReader.js in the jnext folder (this folder is in the same place the HTML sample files are). FileReader.js contains 72 lines of spaced code so it is probably self explanitory, but if not then just follow the comments in the code and the way the wrapper is used in JS-FileReader.html and you'll quickly get the hang of it.

To test your native extension, simple create an HTML file that makes use of it. In the case of the filereader sample this is done in JS-FileReader.html.


-->