Java Code Examples for com.sun.jdi.VirtualMachineManager
https://www.programcreek.com/java-api-examples/index.php?api=com.sun.jdi.VirtualMachineManager
The following are top voted examples for showing how to use com.sun.jdi.VirtualMachineManager. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to product more good examples.
+
Save this class to your library
Example 1
Project: fiji File: StartDebugging.java View source code | 6 votes | ![]() |
private VirtualMachine launchVirtualMachine() { VirtualMachineManager vmm = Bootstrap.virtualMachineManager(); LaunchingConnector defConnector = vmm.defaultConnector(); Transport transport = defConnector.transport(); List<LaunchingConnector> list = vmm.launchingConnectors(); for (LaunchingConnector conn: list) System.out.println(conn.name()); Map<String, Connector.Argument> arguments = defConnector.defaultArguments(); Set<String> s = arguments.keySet(); for (String string: s) System.out.println(string); Connector.Argument mainarg = arguments.get("main"); String s1 = System.getProperty("java.class.path"); mainarg.setValue("-classpath \"" + s1 + "\" fiji.MainClassForDebugging " + plugInName); try { return defConnector.launch(arguments); } catch (IOException exc) { throw new Error("Unable to launch target VM: " + exc); } catch (IllegalConnectorArgumentsException exc) { IJ.handleException(exc); } catch (VMStartException exc) { throw new Error("Target VM failed to initialize: " + exc.getMessage()); } return null; }
Example 2
Project: proxyhotswap File: JDIRedefiner.java View source code | 6 votes | ![]() |
private VirtualMachine connect(int port) throws IOException { VirtualMachineManager manager = Bootstrap.virtualMachineManager(); // Find appropiate connector List<AttachingConnector> connectors = manager.attachingConnectors(); AttachingConnector chosenConnector = null; for (AttachingConnector c : connectors) { if (c.transport().name().equals(TRANSPORT_NAME)) { chosenConnector = c; break; } } if (chosenConnector == null) { throw new IllegalStateException("Could not find socket connector"); } // Set port argument AttachingConnector connector = chosenConnector; Map<String, Argument> defaults = connector.defaultArguments(); Argument arg = defaults.get(PORT_ARGUMENT_NAME); if (arg == null) { throw new IllegalStateException("Could not find port argument"); } arg.setValue(Integer.toString(port)); // Attach try { System.out.println("Connector arguments: " + defaults); return connector.attach(defaults); } catch (IllegalConnectorArgumentsException e) { throw new IllegalArgumentException("Illegal connector arguments", e); } }
Example 3
Project: robovm-eclipse File: AbstractLaunchConfigurationDelegate.java View source code | 6 votes | ![]() |
private VirtualMachine attachToVm(IProgressMonitor monitor, int port) throws CoreException { VirtualMachineManager manager = Bootstrap.virtualMachineManager(); AttachingConnector connector = null; for (Iterator<?> it = manager.attachingConnectors().iterator(); it.hasNext();) { AttachingConnector con = (AttachingConnector) it.next(); if ("dt_socket".equalsIgnoreCase(con.transport().name())) { connector = con; break; } } if (connector == null) { throw new CoreException(new Status(IStatus.ERROR, RoboVMPlugin.PLUGIN_ID, "Couldn't find socket transport")); } Map<String, Argument> defaultArguments = connector.defaultArguments(); defaultArguments.get("hostname").setValue("localhost"); defaultArguments.get("port").setValue("" + port); int retries = 60; CoreException exception = null; while (retries > 0) { try { return connector.attach(defaultArguments); } catch (Exception e) { exception = new CoreException(new Status(IStatus.ERROR, RoboVMPlugin.PLUGIN_ID, "Couldn't connect to JDWP server at localhost:" + port, e));