< prev index next >

test/java/nio/channels/spi/SelectorProvider/inheritedChannel/Launcher.java

Print this page


   1 /*
   2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * A Launcher to launch a java process with its standard input, output,
  26  * and error streams connected to a socket.
  27  */
  28 import java.net.*;
  29 import java.nio.channels.*;
  30 import java.io.IOException;





  31 
  32 public class Launcher {
  33 
  34     static {
  35         System.loadLibrary("Launcher");
  36     }
  37 
  38     private static native void launch0(String cmdarray[], int fd) throws IOException;
  39 
  40     private static void launch(String className, String options[], String args[], int fd) throws IOException {
  41         // java [-options] class [args...]
  42         int optsLen = (options == null) ? 0 : options.length;
  43         int argsLen = (args == null) ? 0 : args.length;
  44         int len = 1 + optsLen + 1 + argsLen;
  45         String cmdarray[] = new String[len];
  46         int pos = 0;
  47         cmdarray[pos++] = Util.javaCommand();
  48         if (options != null) {
  49             for (String opt: options) {
  50                 cmdarray[pos++] = opt;


   1 /*
   2  * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * A Launcher to launch a java process with its standard input, output,
  26  * and error streams connected to a socket.
  27  */


  28 import java.io.IOException;
  29 import java.net.InetAddress;
  30 import java.net.InetSocketAddress;
  31 import java.nio.channels.DatagramChannel;
  32 import java.nio.channels.ServerSocketChannel;
  33 import java.nio.channels.SocketChannel;
  34 
  35 public class Launcher {
  36 
  37     static {
  38         System.loadLibrary("Launcher");
  39     }
  40 
  41     private static native void launch0(String cmdarray[], int fd) throws IOException;
  42 
  43     private static void launch(String className, String options[], String args[], int fd) throws IOException {
  44         // java [-options] class [args...]
  45         int optsLen = (options == null) ? 0 : options.length;
  46         int argsLen = (args == null) ? 0 : args.length;
  47         int len = 1 + optsLen + 1 + argsLen;
  48         String cmdarray[] = new String[len];
  49         int pos = 0;
  50         cmdarray[pos++] = Util.javaCommand();
  51         if (options != null) {
  52             for (String opt: options) {
  53                 cmdarray[pos++] = opt;


< prev index next >