Skip to content

darshanparajuli/JShellSession

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

JShellSession

A simple Java library for running shell commands.

Simple example

// create new JShellSession object
// Config.defaultConfig().builder() can be used to customize the default Config object
try (final JShellSession session = new JShellSession(Config.defaultConfig())) {
    // run command, i.e "echo hello world"
    final CommandResult result = session.run("echo hello world");

    // check if command ran successfully
    if (result.exitSuccess()) {
        // process stdout or stderr (using result.stdErr())
        for (String s : result.stdOut()) {
            System.out.println(s);
        }
    } else {
        System.err.println("Exit code: " + result.exitCode());
    }
} catch (IOException e) {
    e.printStackTrace();
}
Any feedback is much appreciated.

😎

Releases

No releases published

Packages

No packages published

Languages