We can call any exe file from Java code using Runtime class, Runtime class extends Object class and introduced in JDK1.0
What docs says-
Every Java application has a single instance of class
Here we will see how to execute .exe and .bat file from javacode, for executable files we just pass file path and Runtime class will invoke it. But for batch file we have to first open supporting application i;e Command Promt and then provide path for batch file
See Java Programs for both case:
What docs says-
Every Java application has a single instance of class
Runtime
that allows the application to interface with the environment in which the application is running. The current runtime can be obtained from the getRuntime
method.
An application cannot create its own instance of this class.
Here we will see how to execute .exe and .bat file from javacode, for executable files we just pass file path and Runtime class will invoke it. But for batch file we have to first open supporting application i;e Command Promt and then provide path for batch file
See Java Programs for both case: