The moose likes Servlets and the fly likes Incompatible type for declaration.Can't convert java.lang.String to java.lang.Process Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Incompatible type for declaration.Can Watch "Incompatible type for declaration.Can New topic
Author

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

Amithkumar Kota
Greenhorn

Joined: Jul 26, 2001
Posts: 10
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
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

Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Incompatible type for declaration.Can't convert java.lang.String to java.lang.Process
 
Similar Threads
Process err- not a valid Win32 application
getRuntime question
Returning data from an array
command execution
how can i compile a file on the server using a button in jsp..