tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Java Scripting > BeanShell > Exec Command

Exec Command 

BeanShell is a small, free, embeddable Java source interpreter with object scripting language features, written in Java. BeanShell is a natural scripting language for Java. This requires the library bsh-2.0b4.jar to be in classpath. The following example shows using exec command in beanshell script. It starts an external application using the Java Runtime exec() method.

File Name  :  
/BEAN_SHELL001/config/exec.bsh 
   
exec("notepad.exe");  //Opens a notepad window

//Opens one.css in notepad window once the previous
//notepad window (process) is closed
exec("notepad.exe C:/input/one.css")
   

File Name  :  
com/bethecoder/tutorials/bean_shell/commands/ExecTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.bean_shell.commands;

import java.io.InputStreamReader;

import bsh.EvalError;
import bsh.Interpreter;

public class ExecTest {

  /**
   @param args
   @throws EvalError 
   */
  public static void main(String[] argsthrows EvalError {
    Interpreter interpreter = new Interpreter();
    InputStreamReader reader = new InputStreamReader(
        ExecTest.class.getClassLoader()
        .getResourceAsStream("exec.bsh"));
    
    interpreter.eval(reader);
  }

}
   


                    Print

   



Books Recommendation

 
 
bl  br