Foros del Web » Programación para mayores de 30 ;) » Java »

Duda ejecutar Octave desde código Java

Estas en el tema de Duda ejecutar Octave desde código Java en el foro de Java en Foros del Web. Hola, estoy intentando ejecutar Octave desde un programa Java, se ejecuta pero no como debería, utilizo la típica clase Runtime pero no funciona, si pongo ...
  #1 (permalink)  
Antiguo 13/11/2012, 03:17
Avatar de tofol  
Fecha de Ingreso: febrero-2008
Mensajes: 30
Antigüedad: 16 años, 2 meses
Puntos: 1
Pregunta Duda ejecutar Octave desde código Java

Hola, estoy intentando ejecutar Octave desde un programa Java, se ejecuta pero no como debería, utilizo la típica clase Runtime pero no funciona, si pongo cualquier programa con GUI sí se ejecuta, pero Octave no va bien.

La clase es:

Código:
package probandooctave;

import java.io.BufferedReader;
import java.io.InputStreamReader;


/**
 *
 * @author tobal
 */
public class ProbarOctave {
   
    public ProbarOctave() {

        Process p = null;
        Runtime r = Runtime.getRuntime();
        try {
            
            p = r.exec("/usr/bin/octave");

        } catch (java.lang.Exception e) {
            System.err.println("Octave's execution ERROR:");
            e.printStackTrace();
        }

        BufferedReader is = new BufferedReader(new InputStreamReader(p.
                getInputStream()));

        try {
            
            // Se lee la primera linea
            String aux = is.readLine();
       
            
            
            // Mientras se haya leido alguna linea
            while (aux !=null)
            {
                // Se escribe la linea en pantalla
                System.out.println (aux);
                
                // y se lee la siguiente.
                aux  = is.readLine();
                
            }
        }

        catch (Exception e) {
            System.out.println("Error writing to output stream " + e);
            e.printStackTrace();
        }

    }
}
Y lo llamo desde el main así:

Código:
package probandooctave;

/**
 *
 * @author tobal
 */


public class ProbandoOctave {

    /**
     * @param args the command line arguments
     */
    
    public static void main(String[] args) {
   
        ProbarOctave octavito =new ProbarOctave();
   
    }
}
Y al ejecutarlo sale esto:

Código:
run:
GNU Octave, version 3.6.3
Copyright (C) 2012 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type `warranty'.

Octave was configured for "i586-mandriva-linux-gnu".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/help-wanted.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.

For information about changes from previous versions, type `news'.
Y no me deja interactuar con el programa. Lo ejecuto desde NetBeans, no se si ese es el problema.
Debería salir esto:

Código:
tobal@localhost ~ $ octave
GNU Octave, version 3.6.3
Copyright (C) 2012 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type `warranty'.

Octave was configured for "i586-mandriva-linux-gnu".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/help-wanted.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.

For information about changes from previous versions, type `news'.

octave:1>
Como se ve no me sale desde Java el prompt octave:1> que es el que sirve para interactuar con el programa.

He consultado libros, páginas web, etc y todos ponen lo mismo.
Otra duda de lo mismo, si consigo que se ejecute correctamente, mi idea es llevarlo a un GUI con Swing, pero no se qué caja de texto es la conveniente para mostrarla, ¿cuál sería?

Gracias
__________________
http://linuxmusica.com

Etiquetas: clase, netbeans, octave, programa, string
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:55.