AYUDA URGENTE: ERROR EN JAVA NECESITO SOLUCION
Nical.java:336: cannot resolve symbol
symbol : method exec (java.lang.String,java.lang.String)
location: class java.lang.Runtime
Runtime.getRuntime().exec("Notepad","c:texto.txt");
^
*** ME DA EL ERROR EN LA LETRA "a".
haber si me podeis echar una mano MUCHAS GRACIAS
symbol : method exec (java.lang.String,java.lang.String)
location: class java.lang.Runtime
Runtime.getRuntime().exec("Notepad","c:texto.txt");
^
*** ME DA EL ERROR EN LA LETRA "a".
haber si me podeis echar una mano MUCHAS GRACIAS
Los parámetros se deben pasar como un array de String, por eso no te reconoce:
exec(String, String), sino que pide exec(String, String[]). Lo más fácil es que directamente le pases el parámetro en la String de Notepad:
Runtime.getRuntime().exec("Notepad c:texto.txt");
exec(String, String), sino que pide exec(String, String[]). Lo más fácil es que directamente le pases el parámetro en la String de Notepad:
Runtime.getRuntime().exec("Notepad c:texto.txt");
ahora en donde me da un error es la letra " o " de notepa y lo pongo con tu dices. Haber si sabes alguna solucion.
Acabo de correr esto en mi maquina y trabajo bien.
------------------------------------------------
import java.io.IOException;
public class appLauncher
{
public static void main(String args[]) {
Runtime rt = Runtime.getRuntime();
String[] callAndArgs = { "Notepad.exe","C:\setupSDKToolkitLog.txt" };
try {
Process child = rt.exec(callAndArgs);
child.waitFor();
System.out.println("0 = exitoso, 1 = error:" + child.exitValue());
}
catch(IOException e) {
System.err.println("IOException starting process!");
}
catch(InterruptedException e) {
System.err.println("Interrupted waiting for process!");
}
}
}
------------------------------------------------
------------------------------------------------
import java.io.IOException;
public class appLauncher
{
public static void main(String args[]) {
Runtime rt = Runtime.getRuntime();
String[] callAndArgs = { "Notepad.exe","C:\setupSDKToolkitLog.txt" };
try {
Process child = rt.exec(callAndArgs);
child.waitFor();
System.out.println("0 = exitoso, 1 = error:" + child.exitValue());
}
catch(IOException e) {
System.err.println("IOException starting process!");
}
catch(InterruptedException e) {
System.err.println("Interrupted waiting for process!");
}
}
}
------------------------------------------------
