Java how to invoke executable files and batch processing commands
Source: Internet
Author: User
Executive Introduction
Java is a cross-platform language, and we often encounter programs that require Java to invoke Windows. Some third-party vendors, such as ANT, also provide a way to invoke executable programs under Windows, but we often need to invoke some batch commands. But Java does not provide.
Here, I'm using a disguised calling method that allows Java to invoke the batch command. If you have a better way, I hope you can tell me.
Pre-preparation [/b]
Quick Batch File (De) Compiler
Compile any bat, cmd batch script as EXE!
Begin
1. Running EXE files
The Java JDK has already provided a method of invocation, not cumbersome, as the following code.
2. Run Bat (Batch) file
Java is not yet supported for batch files. I've been studying Java how to invoke a batch file and never find a workaround. Later, we had to bypass the batch process and consider how to convert the batch to an EXE executable file. The executable file is then invoked through Java.
Search on Google, find quick Batch file (De) Compiler, can be any bat, cmd batch script compiled to EXE file. Used a bit, sure enough.
Quick Batch File (De) compiler is very simple to use:
QUICKBFC filename. bat file name. exe (compile batch command to executable file)
QUICKBFD file name. exe file name. BAT (decompile executable to Batch command)
Then, we can invoke the first method through Java.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.