Executing compiled jar file from .NET (System.Diag

2019-09-08 15:13发布

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条回答
Emotional °昔
2楼-- · 2019-09-08 15:27

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"
查看更多
登录 后发表回答