jsh

jsh - the "Java Shell".

License

License

GroupId

GroupId

de.unkrig
ArtifactId

ArtifactId

jsh
Last Version

Last Version

0.1.2
Release Date

Release Date

Type

Type

jar
Description

Description

jsh
jsh - the "Java Shell".
Project URL

Project URL

https://github.com/janino-compiler/jsh
Source Code Management

Source Code Management

https://github.com/janino-compiler/jsh

Download jsh

How to add to project

<!-- https://jarcasting.com/artifacts/de.unkrig/jsh/ -->
<dependency>
    <groupId>de.unkrig</groupId>
    <artifactId>jsh</artifactId>
    <version>0.1.2</version>
</dependency>
// https://jarcasting.com/artifacts/de.unkrig/jsh/
implementation 'de.unkrig:jsh:0.1.2'
// https://jarcasting.com/artifacts/de.unkrig/jsh/
implementation ("de.unkrig:jsh:0.1.2")
'de.unkrig:jsh:jar:0.1.2'
<dependency org="de.unkrig" name="jsh" rev="0.1.2">
  <artifact name="jsh" type="jar" />
</dependency>
@Grapes(
@Grab(group='de.unkrig', module='jsh', version='0.1.2')
)
libraryDependencies += "de.unkrig" % "jsh" % "0.1.2"
[de.unkrig/jsh "0.1.2"]

Dependencies

compile (3)

Group / Artifact Type Version
jline : jline jar 2.14
org.codehaus.janino : janino jar 3.0.13
de.unkrig.commons : commons-util jar 1.2.13

Project Modules

There are no modules declared in this project.

jsh - The "Java Shell"

Introduction

On popular operating systems (UNIX, MS WINDOWS, MAC OS, ...) exists a plethora of "shells", i.e. programs that read a sequence of "commands" (either from a "script file" or from the console) and execute them: Bourne Shell, BASH, C Shell, Korn Shell, only to mention a few.

JSH is yet another shell program that stands out from these wrt the following aspects:

  • The command syntax is Java. (Not similar to Java, but really Java.)
  • The commands (ls, echo, ...) are not shell-external programs, but classes in the running JVM.
  • The code entered is compiled into Java bytecode, which is loaded into the running JVM, which makes execution tremendously fast.
  • 100% Java - runs on any platform for which a JRE >= 1.7 is available.

These properties open up a whole range of new use cases which you would normally not implement with a shell script:

  • Processing of massive a amounts of data (traditionally, one would use processing tools like PERL or AWK for that).
  • Number crunching (traditionally, one would use specialized environments for that, like MATLAB).

Usage

Get the latest version of the runnable JAR file from here, and run it:

$ java -jar jar-file

Now start typing Java code and see how it executes. Here's an example session:

Welcome, stranger, and speak!
$ System.out.println("HELLO WORLD");
HELLO WORLD
$ for (int i = 0; i < 3; i++) {
>     out("HELLO WORLD"); // Short for "System.out.println()".
> }
HELLO WORLD
HELLO WORLD
HELLO WORLD
$ for (String s : new String[] { "a", "b", "c" }) {
>     out(s);
> }
a
b
c
$ ls(); // Shorthand for "ls.$()".
.bashrc
.bash_history
.bash_profile
.jshrc
$ ls.l().$(); // "l()" activates "long" listing, resembling "ls -l".
-rwx paula\Arno        6437 20.09.2016 13:42:27 .bashrc
-rwx paula\Arno       50409 20.09.2016 13:42:28 .bash_history
-rwx paula\Arno        1494 22.01.2013 22:05:48 .bash_profile
-rwx paula\Arno          56 16.08.2015 20:32:00 .jshrc
$
exit();

For documentation of the available commands (like ls();), download the JAVADOC

https://oss.sonatype.org/content/groups/public/de/unkrig/jsh/_latest-version_/jsh-_latest-version_-javadoc.jar

, and check the documentation of the "JshBase" class.

Licensing

JSH is available under the new BSD license.

Contributing

If you find the concept useful, feel free to use JSH, give feedback, and contribute! The best way to contact me is via a GITHUB issue.

de.unkrig

Versions

Version
0.1.2
0.1.1
0.1.0