Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
进程类中的Java文件路径和url_Java_Url_Process_Filepath - Fatal编程技术网

进程类中的Java文件路径和url

进程类中的Java文件路径和url,java,url,process,filepath,Java,Url,Process,Filepath,如何编辑这些代码以使其正常工作: String[] var1 = { "\"C:\\Program Files\\Internet Explorer\\iexplore.exe" }; String[] var2 = { "http://google.com" }; Runtime runTime = Runtime.getRuntime(); Process process = runTime.exec("\"C:\\Program Files\\Internet Explorer\

如何编辑这些代码以使其正常工作:

 String[] var1 = { "\"C:\\Program Files\\Internet Explorer\\iexplore.exe" };
 String[] var2 = { "http://google.com" };

 Runtime runTime = Runtime.getRuntime();
 Process process = runTime.exec("\"C:\\Program Files\\Internet Explorer\\iexplore.exe\" http://google.com");
 Process process2 = runTime.exec(var1,var2);

第一个“进程”工作正常,但是“进程2”在IE中打开默认站点而不是google.com

这个var1是错误的您在开始时有一个替换的

它必须是:

String[] var1 = { "C:\\Program Files\\Internet Explorer\\iexplore.exe" };
这就是例外的原因

现在根据文件:

您需要在同一数组中传递要执行的命令和参数

因此,它必须是唯一的

Process process2 = runTime.exec(var1);
在哪里

String[] var1 = { "C:\\Program Files\\Internet Explorer\\iexplore.exe", "http://google.com" };

变量1是错误的。开始时,您有一个替换的

它必须是:

String[] var1 = { "C:\\Program Files\\Internet Explorer\\iexplore.exe" };
这就是例外的原因

现在根据文件:

您需要在同一数组中传递要执行的命令和参数

因此,它必须是唯一的

Process process2 = runTime.exec(var1);
在哪里

String[] var1 = { "C:\\Program Files\\Internet Explorer\\iexplore.exe", "http://google.com" };


过程
正在使用以下方法:

public Process exec(String[] cmdarray) throws IOException
public Process exec(String[] cmdarray, String[] envp) throws IOException
在单独的进程中执行指定的命令和参数。 这是一种方便的方法。表单exec(cmdarray)的调用 行为方式与调用exec(cmdarray,null, 空)


process2
正在使用以下方法:

public Process exec(String[] cmdarray) throws IOException
public Process exec(String[] cmdarray, String[] envp) throws IOException
在单独的进程中执行指定的命令和参数 使用指定的环境。这是一种方便的方法。一 表单exec(cmdarray,envp)的调用行为与 与调用exec(cmdarray、envp、null)的方式相同


试着做:

String var1 = "\"C:\\Program Files\\Internet Explorer\\iexplore.exe";
String var2 = "http://google.com";
Process process2 = runTime.exec({var1,var2});


过程
正在使用以下方法:

public Process exec(String[] cmdarray) throws IOException
public Process exec(String[] cmdarray, String[] envp) throws IOException
在单独的进程中执行指定的命令和参数。 这是一种方便的方法。表单exec(cmdarray)的调用 行为方式与调用exec(cmdarray,null, 空)


process2
正在使用以下方法:

public Process exec(String[] cmdarray) throws IOException
public Process exec(String[] cmdarray, String[] envp) throws IOException
在单独的进程中执行指定的命令和参数 使用指定的环境。这是一种方便的方法。一 表单exec(cmdarray,envp)的调用行为与 与调用exec(cmdarray、envp、null)的方式相同


试着做:

String var1 = "\"C:\\Program Files\\Internet Explorer\\iexplore.exe";
String var2 = "http://google.com";
Process process2 = runTime.exec({var1,var2});

以前试过,还是默认IE站点而不是google.comworked:)谢谢,我肯定我试过了,但没有用逗号,还是默认IE站点而不是google.comworked:)谢谢,我肯定我试过了,但没有用逗号