Dolphin
Dolphin

Reputation: 353

Executing CLI commands from Java

I have this API - which I managed to carryout some API steps solely from the CLI without using their GUI. Now I need to execute these CLI commands (i.e. for carrying out these API steps) in Java. When surfing, I couldn't find a helpful link for sample code on how to deal with this. May I know how to execute CLI commands using Java code (say in a Java class)

Appreciate any insight, suggestions or guidance. Many thanks in advance

Upvotes: 0

Views: 592

Answers (2)

leonbloy
leonbloy

Reputation: 76006

You should take a look at ProcessBuilder - or, the older alternative, the several Runtime.getRuntime().exec(...) methods.

Upvotes: 2

Bozho
Bozho

Reputation: 597362

You can execute commands like that:

Runtime.getRuntime().exec("<put command here>");

Upvotes: 5

Related Questions