问题
Trying to integrate the google closure compiler in a batch job of mine and having difficulty getting it to work.
Using command prompt I can enter the following command and get my scripts compiled. (The command is a self explanatory example)
java -jar "compiler.jar" --js_output_file="myOutput.min.js" --js="input1.js" --js="input2.js"
I have tried to replicate this using the System.Diagnostics.Process object but thus far have failed.
I have tried
Dim command As String = BuildCommand(CompilationScripts, Me._Output)
Dim process As New Process
process.Start("compiler.jar", command)
And I have tried
Dim command As String = BuildCommand(CompilationScripts, Me._Output)
Dim process As New Process
process.StartInfo.Arguments = command
process.Start("compiler.jar")
And I have tried
Dim command As String = BuildCommand(CompilationScripts, Me._Output)
Dim process As New Process
process.StartInfo.Arguments = command
process.Start("cmd.exe")
What am I doing wrong?
回答1:
Arguments should be
-jar "compiler.jar" --js_output_file="myOutput.min.js" --js="input1.js" --js="input2.js"
i.e. no java keyword here.
Also set
process.StartInfo.FileName = "java"
EDIT
process.StartInfo.RedirectStandardInput = True
process.StartInfo.CreateNoWindow = False
process.StartInfo.UseShellExecute = False
process.StartInfo.FileName = "java"
来源:https://stackoverflow.com/questions/4930016/executing-compiled-jar-file-from-net-system-diagnostics-process