[英]run jar using bat file in server
I have a application hosted in server. 我在服务器上托管了一个应用程序。 I have a bat file which will run a .jar file.
我有一个bat文件,它将运行一个.jar文件。 The jar is running when i double click on bat/jar.
当我双击蝙蝠/罐子时,罐子正在运行。 But when a integrated it in my application and tried to run the jar, it is not executing.
但是,当将其集成到我的应用程序中并尝试运行jar时,它没有执行。
Here is the code for running bat file : 这是运行bat文件的代码:
<%
Runtime.getRuntime().exec("c:\\windows\\system32\\cmd.exe /c D:\\Create_Confluence.bat");
%>
This code runs, because when we tried creating a folder the cmd runs & creates the folder. 此代码运行,因为当我们尝试创建文件夹时,cmd会运行并创建文件夹。
Here is the code inside bat file for running the .jar: 这是bat文件中用于运行.jar的代码:
"C:\Program Files (x86)\Java\jdk1.7.0_15\bin\java" -jar D:\confluence.jar "D:\\Eclipse\\Fourprojects\\Excel\\Space.xls"
pause
But the jar file is not getting executed. 但是jar文件没有得到执行。
Can somebody help me with this... 有人可以帮我吗...
You have to provide working directory as like below . 您必须提供如下工作目录。
Runtime.getRuntime().exec("c:\\windows\\system32\\cmd.exe /c Create_Confluence.bat", null,"D:\\");
Check this method here in this link 在此链接中检查此方法
public Process exec(String command,
String[] envp,
File dir)
throws IOException
*Parameters: *参数:
command - a specified system command.
command-指定的系统命令。
envp - array of strings, each element of which has environment variable settings in the format name=value, or null if the subprocess should inherit the environment of the current process.
envp-字符串数组,其每个元素都具有名称=值格式的环境变量设置,如果子流程应该继承当前流程的环境,则为null。
dir - the working directory of the subprocess, or null if the subprocess should inherit the working directory of the current process.*
dir-子流程的工作目录;如果子流程应继承当前流程的工作目录,则为null。*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.