Trato de ejecutar una aplicacion externa y cuando corro la aplicacion en el netBeans (IDE) si la ejecuta y todo muy bie. Ahora el problema es cuando lo hago en una pagina web que me marca errores y ya me he dado vueltas y no encuentro la solucion,,,,
dejo mi codigo fuente de la clase de java para que lo revisen,,,
Código:
y aki les dejo el error que me marca la consola de java del navegador...package ejecutar; import java.*; import java.io.File.*; import java.applet.Applet; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main extends Applet{ public Main(String comando){ try{ Runtime rt = Runtime.getRuntime(); System.out.println("Execing " + comando); Process proc = rt.exec(comando); // any error message? StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR"); // any output? StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "OUTPUT"); // kick them off errorGobbler.start(); outputGobbler.start(); // any error??? int exitVal = proc.waitFor(); System.out.println("ExitValue: " + exitVal); rt.runFinalization(); } catch (Throwable t){ t.printStackTrace(); } } public class StreamGobbler extends Thread { InputStream is; String type; StreamGobbler(InputStream is, String type) { this.is = is; this.type = type; } public void run() { try { InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line = null; while ((line = br.readLine()) != null) System.out.println(type + ">" + line); } catch (IOException ioe) { ioe.printStackTrace(); } } } public static void main(String[] args) { Main aplicacion = new Main("c:\\prueba\\ejecutar.bat"); // aplicacion.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }
Código:
y asi tengo los archivos de la clase en una carpeta en c:\ ...java.lang.reflect.InvocationTargetException at com.sun.deploy.util.DeployAWTUtil.invokeAndWait(Unknown Source) at sun.plugin2.applet.Plugin2Manager.runOnEDT(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.RuntimeException: java.lang.InstantiationException: ejecutar.Main at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) Caused by: java.lang.InstantiationException: ejecutar.Main at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) ... 9 more Excepción: java.lang.reflect.InvocationTargetException java.lang.NullPointerException at sun.plugin2.applet.Plugin2Manager.findAppletJDKLevel(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Excepción: java.lang.NullPointerException
Main.html
ejecutar\Main.class
ejecutar\Main$StreamGobbler.class
espero que puedan ayudarme... saludos y hasta luego