The Java 8 jjs interpreter accepts the
-cp / -classpath argument.
After setting the classpath, all the classes become available from within the executable script.
A utility class
com.airhacks.naslib.Inspector in the
naslib.jar (this is an sample jar) becomes available for Nashorn after setting the
#!/usr/bin/jjs -cp ./naslib/target/naslib.jar -fv //built-in variable var args = $ARG; var Inspector = com.airhacks.naslib.Inspector; //class from jar, calling a static method Inspector.inspect(args);
In case this post looks a bit crazy to you, you would enjoy the Java 8 / Java EE 7 "More Power with Less Code" workshop :-).
Web Apps, SPA, PWA with vanilla Java Script (ES 6+), CSS 3 and WebStandards only. As simple as possible, but not simpler. See you at: (Progressive) Web apps, Single Page Apps and WebStandards airhacks workshops at MUC airport, Winter Edition
airhacks.fm the podcast:
Stay in touch: airhacks.news.