VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/java/tests/TestVBox.java@ 29180

Last change on this file since 29180 was 29180, checked in by vboxsync, 15 years ago

TestVBox.java: Made it continue listing VMs after encountering an inaccessible one. Test constants.

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
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
14import org.mozilla.interfaces.*;
15import org.virtualbox.*;
16
17public class TestVBox
18{
19 public static void main(String[] args)
20 {
21 VirtualBoxManager mgr = VirtualBoxManager.getInstance(null);
22
23 System.out.println("\n--> initialized\n");
24
25 try
26 {
27 IVirtualBox vbox = mgr.getVBox();
28 System.out.println("VirtualBox version: " + vbox.getVersion() + "\n");
29
30 /* list all VMs and print some info for each */
31 IMachine[] machs = vbox.getMachines(null);
32 for (IMachine m : machs)
33 {
34 try
35 {
36 System.out.println("VM name: " + m.getName() + ", RAM size: " + m.getMemorySize() + "MB");
37 System.out.println(" HWVirt: " + m.getHWVirtExProperty(HWVirtExPropertyType.Enabled)
38 + ", Nested Paging: " + m.getHWVirtExProperty(HWVirtExPropertyType.NestedPaging)
39 + ", PAE: " + m.getCPUProperty(CPUPropertyType.PAE) );
40 }
41 catch (Throwable e)
42 {
43 e.printStackTrace();
44 }
45 }
46
47 /* do something silly, start the first VM in the list */
48 String m = machs[0].getName();
49 System.out.println("\nAttempting to start VM '" + m + "'");
50 if (mgr.startVm(m, 7000))
51 {
52 System.out.println("started, presss any key...");
53 int ch = System.in.read();
54 }
55 else
56 {
57 System.out.println("cannot start machine "+m);
58 }
59 }
60 catch (Throwable e)
61 {
62 e.printStackTrace();
63 }
64
65 mgr.cleanup();
66
67 System.out.println("\n--< done\n");
68 }
69
70}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette