Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close
JavaSh (Java Shell)
----------

This is an interactive text-only shell (it works well within Emacs) that lets
you execute Java statements and expressions and take a look at the results
where possible. See Javadoc details in doc/. To date this has been tested
mostly on Unix machines, with a quick check on NT 4.0. JDK 1.2 (or equiv.)
will be helpful for inspecting things, but not required; JDK 1.1 probably is
required.

You need some sort of Java compiler to run it. As shipped it assumes that the
JDK javac is available. In order to use a different compiler, you will need to
change one or more of these properties:

com.sig.javash.Main.evaluatorClass
com.sig.javash.InlineEvaluator.compilerClass
com.sig.javash.BasicEvaluator.compiler

Customization: several classes take user-settable options, which are
documented in the API files. These can be set on the Java command line, so a
typical shell script to invoke this might look like:

-----------%<----------- javash
#!/bin/sh
CLASSPATH=..../javash-xxx.jar:$CLASSPATH
java -Dcom.sig.javash.Main.shell='bash -c' com.sig.javash.Main
-----------%<-----------

For NT 4.0, try passing -Dcom.sig.javash.Main.shell="\winnt\system32\cmd /c"
to get the shell to work (all else should work by default). If you use JavaSh
successfully on '95, or on other non-Unix platforms, let me know what works.

A typical session with the shell:

-----------%<-----------
Java Shell version 0.001
For help, type `?'.
javash> ?
Current package: (default)
Current imports:
Usage:
`:' (declare variables)          : String[] $p, int $i
`~' (kill variable)              ~ $x
`*' (list variables)             *
`!' (exec Java)                  ! $i+=1; $p[2]="hello"
`=' (inspect briefly)            = $i * 3
`@' (inspect fully)              @ System.getProperties()
`-' (define)                     - public class Foo {}
`/' (set package)                / test
`>' (import)                     > java.util.*
`<' (unimport)                   < java.io.PrintReader
`$' (exec system)                $ ls -la
`?' (show this help & settings)  ?
`#' (comment)                    # hello kitty
`.' (quit, also EOF)             .
javash> = 1+2
com.sig.javash.Thing warning: cannot inspect private fields: java.lang.NoClassDefFoundError: java/lang/reflect/AccessibleObject
int=3
javash> # Ignore that warning, means we have JDK 1.1.
javash> - public class Test {public static int test(int x) {return x*x;}}
javash> = Test.test(7)
int=49
javash> @ Test.class
public synchronized class Test {
  public Test();
  public static int test(int);
}
extends public synchronized class java.lang.Object {
  public java.lang.Object();
  public final native java.lang.Class getClass();
  public native int hashCode();
  public boolean equals(java.lang.Object);
  protected native java.lang.Object clone() throws java.lang.CloneNotSupportedException;
  public java.lang.String toString();
  public final native void notify();
  public final native void notifyAll();
  public final native void wait(long) throws java.lang.InterruptedException;
  public final void wait(long, int) throws java.lang.InterruptedException;
  public final void wait() throws java.lang.InterruptedException;
  protected void finalize() throws java.lang.Throwable;
}
javash> @ new Test()
class Test {
}
extends class java.lang.Object {
}
// prints as "Test@150fdd"
javash> @ new Exception()
public synchronized class java.lang.Exception {
  public java.lang.Exception();
  public java.lang.Exception(java.lang.String);
}
extends public synchronized class java.lang.Throwable implements java.io.Serializable {
  private transient java.lang.Object backtrace;
  private java.lang.String detailMessage;
  private static final long serialVersionUID;
  public java.lang.Throwable();
  public java.lang.Throwable(java.lang.String);
  public java.lang.String getMessage();
  public java.lang.String getLocalizedMessage();
  public java.lang.String toString();
  public void printStackTrace();
  public void printStackTrace(java.io.PrintStream);
  public void printStackTrace(java.io.PrintWriter);
  private native void printStackTrace0(java.lang.Object);
  public native java.lang.Throwable fillInStackTrace();
}
extends class java.lang.Object {
}
// prints as "java.lang.Exception"
javash> # Under 1.2 those private fields would have been shown.
javash> # Object class common info is not repeated unless specifically asked for:
javash> @ Object.class
public synchronized class java.lang.Object {
  public java.lang.Object();
  public final native java.lang.Class getClass();
  public native int hashCode();
  public boolean equals(java.lang.Object);
  protected native java.lang.Object clone() throws java.lang.CloneNotSupportedException;
  public java.lang.String toString();
  public final native void notify();
  public final native void notifyAll();
  public final native void wait(long) throws java.lang.InterruptedException;
  public final void wait(long, int) throws java.lang.InterruptedException;
  public final void wait() throws java.lang.InterruptedException;
  protected void finalize() throws java.lang.Throwable;
}
javash> .
-----------%<-----------

Source is included together with precompiled classfiles.

Classes can be unpacked or run right out of the jarfile. If you would like for
this to be available as an RPM, please let me know.

Bug reports & suggestions to Jesse Glick <jglick@sig.bsh.com>.

$Format: "Version $JavashRelease$. $JavashCopyright$"$
Version 0.001. Copyright (c) 1998 Strategic Interactive Group. All rights reserved. This software may be redistributed under the terms of the GNU General Public License. There is no warranty whatsoever.

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.