« Project bashj : a bash mutant with java support » : différence entre les versions

De Lillois Fractale Wiki
Aller à la navigation Aller à la recherche
Contenu ajouté Contenu supprimé
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 35 : Ligne 35 :
#run in bash&nbsp;: <span style="font-family:courier new,courier,monospace;">sudo ./jsbInstall</span>
#run in bash&nbsp;: <span style="font-family:courier new,courier,monospace;">sudo ./jsbInstall</span>


== Check and try ==
== Check try test ==


After the installation run these commands in a bash terminal. Their output should be self explanatory.
Examples
<div style="background:#eee;border:1px solid #ccc;padding:5px 10px;">. jsbInit</div> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;">jsbHelp</div> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;">jsbStart</div> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;">jsbStatus</div> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;">jsbClasses</div> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;">jsbMethods</div> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;">jsbFields</div> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;">echo $(jsb Math.hypot 3.0 4.0)</div> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;">echo $(jsb Math.PI)</div> <div style="background:#eee;border:1px solid #ccc;padding:5px 10px;">Examples</div>
It is suggested to try, copy, adapt some examples scripts present in the example subdiretory

== bashJ syntax rules and java calls ==

The bashJ is only available in scripts. It may not be used for an interactive session.

A bashJ file is similar&nbsp;to a standard bash file. Just replace the shebang : <span style="font-family:courier new,courier,monospace;">'''#!/bin/bashJ'''</span> instead of <span style="font-family:courier new,courier,monospace;">'''#!/bin/bash'''</span>.

Three kind of java methods & fields may be called

Those defined in the beginning of the bash file, between a line containing&nbsp;#@javaStart and a line containing&nbsp;#@javaEnd. Java methods are define there without package name and without class name. The implicit method name is "j". So a function&nbsp;public static int factorial(int n) may be called as j.factorial().

Those present&nbsp;

== Configuration ==

No configuration is necessary.

However it is possible for the user to put various jar files under the jarlib directory.

All public static methods and all public static fields defined in these classes will be available in the bridge.

They should be called as indicated before.

== Support ==

Please contact [[fil@gonze.org|fil]] for support.


== Annex&nbsp;: installed Files ==
== Annex&nbsp;: installed Files ==
Ligne 44 : Ligne 72 :


*<span style="font-family:courier new,courier,monospace;">'''JSBServer'''.jar</span> (a jar containing&nbsp;a&nbsp;compiled java class)
*<span style="font-family:courier new,courier,monospace;">'''JSBServer'''.jar</span> (a jar containing&nbsp;a&nbsp;compiled java class)
*'''<span style="font-family:courier new,courier,monospace;">jsbInit</span>''' (a set of bash functions)
*'''<span style="font-family:courier new,courier,monospace;">jsbInit</span>''' (a set of bash functions) (a link is created in /usr/bin)
*'''<span style="font-family:courier new,courier,monospace;">bashJ</span>''' (a script, the command interpreter)
*'''<span style="font-family:courier new,courier,monospace;">bashJ</span>''' (a script, the command interpreter) (a link is created in /usr/bin)
*'''<span style="font-family:courier new,courier,monospace;">README</span>''' a readme file (a short version of this page)
*'''<span style="font-family:courier new,courier,monospace;">README</span>''' a readme file (a short version of this page)
*'''<span style="font-family:comic sans ms,cursive;">pipe/</span>'''as subdirectory used for named pipes
*<span style="font-family:courier new,courier,monospace;">'''pipe/'''</span>a&nbsp;subdirectory used for named pipes
*'''<span style="font-family:courier new,courier,monospace;">classes/</span>''' a subdirectory with transient compiled java classes
*'''<span style="font-family:courier new,courier,monospace;">classes/</span>''' a subdirectory with transient compiled java classes
*<span style="font-family:courier new,courier,monospace;">'''jarlib/'''</span> a subdirectory with the jars choosen by the user to make the involved classes available&nbsp;&nbsp;&nbsp;
*<span style="font-family:courier new,courier,monospace;">'''jarlib/'''</span> a subdirectory with the jars choosen by the user to make the involved classes available&nbsp;&nbsp;&nbsp;
*<span style="font-family:courier new,courier,monospace;">'''example/'''</span> a subdirectory with various example scripts

&nbsp;


&nbsp;
&nbsp;

Version du 10 juin 2018 à 17:43

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 try test

After the installation run these commands in a bash terminal. Their output should be self explanatory.

. jsbInit
jsbHelp
jsbStart
jsbStatus
jsbClasses
jsbMethods
jsbFields
echo $(jsb Math.hypot 3.0 4.0)
echo $(jsb Math.PI)
Examples

It is suggested to try, copy, adapt some examples scripts present in the example subdiretory

bashJ syntax rules and java calls

The bashJ is only available in scripts. It may not be used for an interactive session.

A bashJ file is similar to a standard bash file. Just replace the shebang : #!/bin/bashJ instead of #!/bin/bash.

Three kind of java methods & fields may be called

Those defined in the beginning of the bash file, between a line containing #@javaStart and a line containing #@javaEnd. Java methods are define there without package name and without class name. The implicit method name is "j". So a function public static int factorial(int n) may be called as j.factorial().

Those present 

Configuration

No configuration is necessary.

However it is possible for the user to put various jar files under the jarlib directory.

All public static methods and all public static fields defined in these classes will be available in the bridge.

They should be called as indicated before.

Support

Please contact fil for support.

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) (a link is created in /usr/bin)
  • bashJ (a script, the command interpreter) (a link is created in /usr/bin)
  • README a readme file (a short version of this page)
  • pipe/a 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   
  • example/ a subdirectory with various example scripts