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.
- */
- import org.virtualbox_4_3.IMachine;
- import org.virtualbox_4_3.IProgress;
- import org.virtualbox_4_3.ISession;
- import org.virtualbox_4_3.VirtualBoxManager;
- /**
- * The following piece of code assume that
- * - WebServices server is running
- * - Authentication is disabled
- *
- * To disable authentication, run on the host before starting the server:
- *
- * vboxmanage setproperty websrvauthlibrary null
- *
- */
- public class StartVM {
- public static void main(String[] args) {
- VirtualBoxManager vboxManager = VirtualBoxManager.createInstance(null);
- vboxManager.connect("http://localhost:18083", "", "");
- try {
- IMachine machine = vboxManager.getVBox().findMachine("machineName");
- ISession session = vboxManager.getSessionObject();
- IProgress p = machine.launchVMProcess(session, "headless", null);
- try {
- p.waitForCompletion(-1);
- if (p.getResultCode() != 0) {
- System.out.println("Machine failed to start: " + p.getErrorInfo().getText());
- }
- } finally {
- session.unlockMachine();
- }
- } finally {
- vboxManager.disconnect();
- vboxManager.cleanup();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement