Execute a shell command from Java

1
2
import java.io.BufferedReader;
import java.io.InputStream;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Java offers Runtime class to execute Shell Commands.
Since these are external commands, exception handling is really important.

In above example, it's illustrated with a simple example.
It tries to open a PDF file from Shell command.

#java #externalCommands #pdf #shell

#cesarnog

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.