RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
Launch.java
1/*
2 * Copyright (c) 2013 Creative Sphere Limited.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing,
9 * software distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 *
14 * Contributors:
15 *
16 * Creative Sphere - initial API and implementation
17 *
18 */
19package robotCore;
20
21import org.ah.java.remotevmlauncher.client.LaunchRemote;
22
28public class Launch {
29 public static void main(String[] args) throws Exception {
30 LaunchRemote client = new LaunchRemote();
31
32// System.out.println(String.format("Launch: %d", args.length));
33
34 client.run(args);
35
36// int debugLevel = 0;
37//
38// boolean remoteClasspath = false;
39// boolean excludeClasspath = false;
40// boolean addressAndPort = true;
41// boolean mainClass = true;
42// boolean arguments = false;
43// boolean allRead = false;
44// boolean debugLevelFlag = false;
45// boolean remoteDebugPortFlag = false;
46// boolean remoteVMarg = false;
47// for (String arg : args) {
48// if (!arguments) {
49// if (remoteClasspath) {
50// client.remoteClasspathProcessor.getRemoteClasspath().add(arg);
51// remoteClasspath = false;
52// } else if (excludeClasspath) {
53// client.excludeClassPath.add(arg);
54// excludeClasspath = false;
55// } else if (debugLevelFlag) {
56// debugLevel = Integer.parseInt(arg);
57// client.startRemoteVMProcessor.getLauncherArgs().add("-d");
58// client.startRemoteVMProcessor.getLauncherArgs().add(Integer.toString(Integer.parseInt(arg)));
59// debugLevelFlag = false;
60// } else if (remoteDebugPortFlag) {
61// client.startRemoteVMProcessor.setRemoteDebugPort(Integer.parseInt(arg));
62// remoteDebugPortFlag = false;
63// } else if (remoteVMarg) {
64// client.startRemoteVMProcessor.getVmArgs().add(arg);
65// remoteVMarg = false;
66// } else if ("-rcp".equals(arg) || "--remote-classpath".equals(arg)) {
67// remoteClasspath = true;
68// } else if ("-ecp".equals(arg) || "--exclude-classpath".equals(arg)) {
69// excludeClasspath = true;
70// } else if ("-d".equals(arg) || "--debug".equals(arg)) {
71// debugLevelFlag = true;
72// } else if ("-rdp".equals(arg) || "--remote-debug-port".equals(arg)) {
73// remoteDebugPortFlag = true;
74// } else if ("-rds".equals(arg) || "--remote-debug-suspend".equals(arg)) {
75// client.startRemoteVMProcessor.setRemoteDebugSuspendAtStart(true);
76// } else if ("-rvma".equals(arg) || "--remote-VM-argment".equals(arg)) {
77// remoteVMarg = true;
78// } else if ("-h".equals(arg) || "--help".equals(arg)) {
79// printHelp();
80// System.exit(0);
81// } else if (addressAndPort) {
82// int i = arg.indexOf(':');
83// if (i < 0) {
84// client.setRemoteAgentSocketAddress(new InetSocketAddress(Integer.parseInt(arg)));
85// } else {
86// client.setRemoteAgentSocketAddress(new InetSocketAddress(arg.substring(0, i), Integer.parseInt(arg.substring(i + 1))));
87// }
88// addressAndPort = false;
89// mainClass = true;
90// } else if (mainClass) {
91// client.mainClassProcessor.setMainClass(arg);
92// mainClass = false;
93// allRead = true;
94// } else if (allRead) {
95// if ("--".equals(arg)) {
96// allRead = false;
97// arguments = true;
98// } else {
99// System.out.println("ERROR: unknown argument '" + arg + "'");
100// System.out.println();
101// printHelp();
102// System.exit(1);
103// }
104// } else {
105// System.out.println("ERROR: unknown argument '" + arg + "'");
106// System.out.println();
107// printHelp();
108// System.exit(1);
109// }
110// } else {
111// client.argumentsProcessor.getArguments().add(arg);
112// }
113// }
114// if (addressAndPort) {
115// System.out.println("ERROR: missing address and port argument.");
116// System.out.println();
117// printHelp();
118// System.exit(1);
119// }
120// if (mainClass) {
121// System.out.println("ERROR: missing main class argument.");
122// System.out.println();
123// printHelp();
124// System.exit(1);
125// }
126//
127// JavaLoggingUtils.setupSimpleConsoleLogging(debugLevel);
128//
129// client.setup();
130//
131// client.start();
132 }
133
134 public static void printHelp() {
135 System.out.println("Remote VM Launcher usage:");
136 System.out.println("");
137 System.out.println("java -jar remotevmlauncher-client.jar {options} [address:]port mainClass");
138 System.out.println("");
139 System.out.println("Options:");
140 System.out.println("");
141 System.out.println(" -rcp|--remote-classpath classpath-entry");
142 System.out.println(" classpath entry as seen from remote machine");
143 System.out.println(" where agent is running.");
144 System.out.println(" -ecp|--exclude-classpath classpath-entry");
145 System.out.println(" classpath entry not to be send to the remote");
146 System.out.println(" machine where agent is running.");
147 System.out.println(" -d|--debug level debug level from 0 to 4. Default: 0");
148 System.out.println(" -rdp|--remote-debug-port port ");
149 System.out.println(" If port is specified remote VM will be launched");
150 System.out.println(" in debug mode at the specified port.");
151 System.out.println(" -rds|--remote-debug-suspend ");
152 System.out.println(" If port is specified and if this flag as well");
153 System.out.println(" remote VM will be suspended.");
154 System.out.println(" -h|--help this help.");
155 System.out.println("");
156 System.out.println("If launcher is used from an IDE, and ");
157 System.out.println(" org.ah.java.remotevmlauncher.client.LaunchRemote class is directly used as");
158 System.out.println("main class, then supplied classpath will automatically used (provided that it");
159 System.out.println("is defined as URLClassLoader or descendant class) on the remote side.");
160 System.out.println("");
161 System.out.println("Note: if remote debug port is specified launcher's VM is started with:");
162 System.out.println("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=(y|n),address=<port>");
163 System.out.println("depending on port and if suspend is specified or not.");
164 }
165
166}