• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

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

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic