code: public static void main( String [] args )
      {
          if ( args.length > 0 ) {
              String filename = args[0];
  
              String [] bshArgs;
              if ( args.length > 1 ) {
                  bshArgs = new String [ args.length -1 ];
                  System.arraycopy( args, 1, bshArgs, 0, args.length-1 );
              } else
                  bshArgs = new String [0];
  
              try {
                  Interpreter interpreter = new Interpreter();
                  interpreter.setu( "bsh.args", bshArgs );
                  Object result =
                      interpreter.source( filename, interpreter.globalNameSpace );
                  if ( result instanceof Class )
                      try {
                          invokeMain( (Class<?>)result, bshArgs );
                      } catch ( Exception e )
                      {
                          Object o = e;
                          if ( e instanceof InvocationTargetException )
                              o = e.getCause();
                          System.err.println(
                              "Class: "+result+" main method threw exception:"+o);
                      }
              } catch ( FileNotFoundException e ) {
                  System.err.println("File not found: "+e);
              } catch ( TargetError e ) {
                  System.err.println("Script threw exception: "+e);
                  if ( e.inNativeCode() )
                      e.printStackTrace( DEBUG.get(), System.err );
              } catch ( EvalError e ) {
                  System.err.println("Evaluation Error: "+e);
              } catch ( IOException e ) {
                  System.err.println("I/O Error: "+e);
              }
          } else {
              @SuppressWarnings("resource")
              Interpreter interpreter =
              new Interpreter(new CommandLineReader(
                  new FileReader(System.in)),
                  System.out, System.err, true );
              interpreter.run();
          }
      }
docs: Run the text only interpreter on the command line or specify a file.