This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Incompatible type for declaration.Can't convert java.lang.String to java.lang.Process

 
Amithkumar Kota
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!