1 | /* $Id:$ */
|
---|
2 | /*
|
---|
3 | * Copyright (C) 2010 Oracle Corporation
|
---|
4 | *
|
---|
5 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
6 | * available from http://www.virtualbox.org. This file is free software;
|
---|
7 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
8 | * General Public License (GPL) as published by the Free Software
|
---|
9 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
10 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
11 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
12 | */
|
---|
13 |
|
---|
14 | import org.mozilla.interfaces.*;
|
---|
15 | import org.virtualbox.*;
|
---|
16 |
|
---|
17 | public class TestVBox
|
---|
18 | {
|
---|
19 | public static void main(String[] args) {
|
---|
20 | VirtualBoxManager mgr = VirtualBoxManager.getInstance(null);
|
---|
21 |
|
---|
22 | System.out.println("\n--> initialized\n");
|
---|
23 |
|
---|
24 | try {
|
---|
25 |
|
---|
26 | IVirtualBox vbox = mgr.getVBox();
|
---|
27 |
|
---|
28 | System.out.println("vers="+vbox.getVersion());
|
---|
29 | IMachine[] machs = vbox.getMachines(null);
|
---|
30 | //IMachine m = vbox.findMachine("SL");
|
---|
31 | for (IMachine m : machs)
|
---|
32 | {
|
---|
33 | System.out.println("mach="+m.getName()+" RAM="+m.getMemorySize()+"M");
|
---|
34 | }
|
---|
35 |
|
---|
36 | String m = machs[0].getName();
|
---|
37 | if (mgr.startVm(m, 7000))
|
---|
38 | {
|
---|
39 | System.out.println("started, presss any key...");
|
---|
40 | int ch = System.in.read();
|
---|
41 | }
|
---|
42 | else
|
---|
43 | {
|
---|
44 | System.out.println("cannot start machine "+m);
|
---|
45 | }
|
---|
46 | } catch (Throwable e) {
|
---|
47 | e.printStackTrace();
|
---|
48 | }
|
---|
49 |
|
---|
50 | mgr.cleanup();
|
---|
51 |
|
---|
52 | System.out.println("\n--< done\n");
|
---|
53 | }
|
---|
54 |
|
---|
55 | }
|
---|