Incompatible type for declaration.Can't convert java.lang.String to java.lang.Process
Amithkumar Kota
Greenhorn
Joined: Jul 26, 2001
Posts: 10
posted
0
I am getting the following message when i try to do this to execute using JSP. /command.jsp.java:11: Incompatible type for declaration. Can't convert java.lang.String to java.lang.Process. Process p="null"; ^ 1 error can anyone please tell me why is this happening and how to correct it... the code for command.jsp is <% String compilefile="none"; String runfile="none"; compilefile = request.getParameter("compile"); runfile = request.getParameter("run"); %> <%!public String command(String compile){ Process p="null"; BufferedReader inStream = null; Runtime r = Runtime.getRuntime(); // try executing the command try { p = r.exec("make"); return("files compiled"); } catch(IOException e) { System.out.println("Error executing compile"); } return(" not compiled"); // read results from process standard output try { inStream = new BufferedReader(new InputStreamReader(p.getInputStream())); System.out.println(inStream.readLine()); return("this is it"); } catch(IOException e) { System.out.println(e); } return("this is not it");
}%> <% if (compilefile!="null" && runfile=="null"){ command(compilefile); } if (compilefile=="null" && runfile!="null"){ command(runfile); } %> -kota
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12266
1
posted
0
The error message says it all. /command.jsp.java:11: Incompatible type for declaration. Can't convert java.lang.String to java.lang.Process. Process p="null"; ^ " You probably meant to do: Process p = null ; // without quotes. "null" is a string literal null is the special null literal