Project bashj : a bash mutant with java support
What ?
The bashJ & java Shell Bridge project is hosted on sourceForge.
bashJ is an extended bash allowing to use java libraries and java code in scripts.
Java Shell Bridge is the underlying technology used by bashJ. It is mainly a server excuting java code for the benefit of a bash session (interactive or scripted).
Why ?
Java and bash are often partners in software projects.
Their possible interactions are numerous but limited in terms of integration.
With this project, any script is given the capacity to quicly and directly call java methods without creating new OS processes.
Limitations
. bash only
. Linux only
. public static methods only
. methods with primitive types (including String) as parameters and return value
. no varargs
. requires java 9+
Installation
Follow carefully these steps:
- create a directory /var/lib/jsbridge/
- download from sourceForge the jsbInstall.jar installation file and put it in this directory
- go to the installation directory : cd /var/lib/jsbridge/
- run in bash :jar xvf jsbInstall.jar
- run in bash : sudo ./jsbInstall
Check and try
Examples
Annex : installed Files
The files are installed under /var/lib/jsbridge/, and include:
- JSBServer.jar (a jar containing a compiled java class)
- jsbInit (a set of bash functions)
- bashJ (a script, the command interpreter)
- README a readme file (a short version of this page)
- pipe/as subdirectory used for named pipes
- classes/ a subdirectory with transient compiled java classes
- jarlib/ a subdirectory with the jars choosen by the user to make the involved classes available