Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
- * Version 2, December 2004
- *
- * Everyone is permitted to copy and distribute verbatim or modified
- * copies of this license document, and changing it is allowed as long
- * as the name is changed.
- *
- * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
- * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- *
- * 0. You just DO WHAT THE FUCK YOU WANT TO.
- */
- public class ListRunningVms {
- public static void main(String[] args) {
- VirtualBoxManager vboxManager = VirtualBoxManager.createInstance(null);
- try {
- vboxManager.connect("http://localhost:18083", "user", "password"); // only if you are using WebServices Bindings
- IVirtualBox vbox = vboxManager.getVBox();
- for (IMachine vm : vbox.getMachines()) {
- if (MachineState.Running.equals(vm.getState())) {
- System.out.println(vm.getName()+ " "+vm.getId());
- }
- }
- } finally {
- vboxManager.disconnect(); // only if you are using WebServices Bindings
- vboxManager.cleanup();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement