我必须在Java中执行以下Windows的cmd
命令。如何在Java中更改目录并执行文件
的cmd
命令:
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
//First i have to change my default directory//
C:\Users\shubh>D:
//Then move to a specific folder in the D drive.//
D:\>cd MapForceServer2017\bin\
//then execute the .mfx file from there.
D:\MapForceServer2017\bin>mapforceserver run C:\Users\shubh\Desktop\test1.mfx
执行
Output files:
library: C:\Users\shubh\Documents\Altova\MapForce2017\MapForceExamples\Tutorial\library.xml
Execution successful.
你为什么不尝试在Windows的.bat脚本?只是一个想法! – harshavmb
我希望在我的servlet文件中添加上述命令的java代码,用户将上传文件,然后它将被mapforceserver run命令使用。因此,每次用户上传新文件时,文件名都会更改。我们可以在运行期间动态更改批处理文件的内容吗? – shubham0001
是的,你可以使用java.io.File API编写,通过下面的链接。 http://stackoverflow.com/questions/29820079/write-into-bat-file-with-java – harshavmb