Project bashj : a bash mutant with java support

De Lillois Fractale Wiki
Aller à la navigation Aller à la recherche

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
  • java 9+
  • public static methods only
  • methods with primitive types (including String) as parameters and return value
  • no varargs

Installation

Follow carefully these steps:

  1. create a directory  /var/lib/jsbridge/
  2. download from  sourceForge the jsbInstall.jar installation file and put it in this directory
  3. go to the installation directory : cd /var/lib/jsbridge/
  4. run in bash :jar xvf  jsbInstall.jar
  5. 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