Foros del Web » Programando para Internet » PHP »

Ejecutar .java en el servidor

Estas en el tema de Ejecutar .java en el servidor en el foro de PHP en Foros del Web. Buenos días. Quería que cuando haga click en un enlace, me ejecute este .java en el servidor. Código: /* * Copyright (c) 2011 Juniper Networks, ...
  #1 (permalink)  
Antiguo 16/02/2012, 05:48
 
Fecha de Ingreso: enero-2012
Mensajes: 7
Antigüedad: 12 años, 2 meses
Puntos: 0
Ejecutar .java en el servidor

Buenos días.

Quería que cuando haga click en un enlace, me ejecute este .java en el servidor.

Código:
/*
 * Copyright (c) 2011 Juniper Networks, Inc.
 * All Rights Reserved
 *
 * JUNIPER PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 */

import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import net.juniper.netconf.CommitException;
import net.juniper.netconf.LoadException;
import net.juniper.netconf.NetconfException;
import org.xml.sax.SAXException;

import net.juniper.netconf.Device;
import net.juniper.netconf.XML;
import net.juniper.netconf.XMLBuilder;


public class EditConfiguration {
    public static void main(String[] args) throws LoadException, IOException, 
            NetconfException, ParserConfigurationException, SAXException {
        
        /*Build the XML configuration
         *The XML configuration required is:
         *
         * <configuration>
         *     <system>
         *         <services>
         *             <ftp/>
         *         </services>
         *     </system>
         * </configuration>
         */
         XMLBuilder builder = new XMLBuilder();
         XML ftp_config = builder.createNewConfig("system", "services", "ftp");

         //Create the device
         Device device = new Device("10.64.164.19","admin","*******",null);
         device.connect();

         //Lock the configuration first
         boolean isLocked = device.lock_config();
         if(!isLocked) {
             System.out.println("Could not lock configuration. Exit now.");
             return;
         }

         //Load and commit the configuration
         try {
             device.loadXMLConfiguration(ftp_config.toString(), "merge");
             device.commit();
         } catch(LoadException e) {
             System.out.println(e.getMessage());
             return;
         } catch(CommitException e) {
             System.out.println(e.getMessage());
             return;
         }

         //Unlock the configuration and close the device.
         device.unlock_config();
         device.close();
    }
}
Este código depende de un .jar (Netconf)

Podrían echarme una mano. Muchas gracias
  #2 (permalink)  
Antiguo 17/02/2012, 00:28
Avatar de repara2  
Fecha de Ingreso: septiembre-2010
Ubicación: München
Mensajes: 2.445
Antigüedad: 13 años, 7 meses
Puntos: 331
Respuesta: Ejecutar .java en el servidor

Utiliza http://de2.php.net/manual/en/function.exec.php para ejecutar programas desde linea de comandos.
Saludos
__________________
Fere libenter homines, id quod volunt, credunt.
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 23:33.