Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== pluggablejs ====== [[:|Projects index]] ===== Details ===== * Current version: 1.1.1build36, published on July 5th 2008 * Released under a [[http://www.linfo.org/bsdlicense.html|Two-clause BSD license]] * Requires at least [[http://sun.java.com|Java]] v6 ===== Description ===== pluggablejs is a wrapper around Java's built-in JavaScript engine intended to load pieces of JavaScript code as plugins for programs. \\ It's a part of some of my Java programs, others can use it although in many cases an ad-hoc solution might be preferable. Additionally it [[#shell_usage|can be used as a shell]] to run arbitrary JavaScript code with some extra convenience objects available, although for such uses [[http://www.beanshell.org/|BeanShell (bsh)]] makes a lot more sense. \\ My own, much simpler, [[:javacode#RhinoRun]] can also be used to run arbitrary JavaScript. ===== Download ===== * Binary jar * [[/files/pluggablejs/pluggablejs-1.1.1build36.jar|pluggablejs-1.1.1build36.jar]] * ''net.outlyer.plugins.Shell'' wrappers * Windows\\ \_ [[/files/pluggablejs/pjsh.cmd|pjsh.cmd]] * Linux/Unix\\ \_ [[/files/pluggablejs/pjsh.sh|pjsh.sh]] * [[//www.debian.org/|Debian]] binary package * [[deb>files/pluggablejs/libpluggablejs-java_1.1.1build36-upstream.0_all.deb|libpluggablejs-java_1.1.1build36-upstream.0_all.deb]] * Source jar * [[/files/pluggablejs/pluggablejs-1.1.1build36-src.jar|pluggablejs-1.1.1build36-src.jar]] * <del>Source code</del> Will upload soon, see the source jar instead * <del>pluggablejs-1.1.1.tar.gz\\ Includes source code and some sample usages.</del ===== "Shell" usage ===== Code run in the shell has access a default set of utilities (more details to come). ==== Running a script ==== ''$ java net.outlyer.plugins.Shell file.js'' ==== Hello world and pals ==== <file javascript helloworld.js> out.println("Hello World!") </file> $ java -cp pluggablejs.jar net.outlyer.plugins.Shell helloworld.js Hello World! ---- <file javascript namedhello.js> out.println("Hello " + ui.prompt("What's your name?")) </file> $ java -cp pluggablejs.jar net.outlyer.plugins.Shell namedhello.js What's your name?: Toni Hello Toni ---- <file javascript hellobye.js> // Includes usage of callbacks and reference to variables defined later on hooks.atexit(function() { out.println('And bye '+you+'!') }); var you = ui.prompt("What's your name?") out.printf("Hello %s!\n", new Array(you)) </file> $ java -cp pluggablejs.jar net.outlyer.plugins.Shell hellobye.js What's your name?: Toni Hello Toni! And bye Toni! ---- <file javascript plainjava.js> java.lang.System.out.println("Hello world without wrapping"); </file> $ java -cp pluggablejs.jar net.outlyer.plugins.Shell plainjava.js Hello world without wrapping ===== Caveats ===== * The first line is evaluated twice, so it shouldn't have side effects. ===== TBD: More details to come ===== ---- <html><address style="font-size:small;text-align:right;font-style:italic">© 2008 Toni Corvera <outlyer at gmail dot com></address></html> All dates/times in this page are UTC. pluggablejs.txt Last modified: 2017/05/19 01:31by Toni Corvera Log In