VirtualBox

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

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

some improvements to the Java API sample

  • Property svn:eol-style set to native
File size: 1.8 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 System.out.println("VM name: " + m.getName() + ", RAM size: " + m.getMemorySize() + "MB");
35 }
36
37 /* do something silly, start the first VM in the list */
38 String m = machs[0].getName();
39 System.out.println("\nAttempting to start VM '" + m + "'");
40 if (mgr.startVm(m, 7000))
41 {
42 System.out.println("started, presss any key...");
43 int ch = System.in.read();
44 }
45 else
46 {
47 System.out.println("cannot start machine "+m);
48 }
49 }
50 catch (Throwable e)
51 {
52 e.printStackTrace();
53 }
54
55 mgr.cleanup();
56
57 System.out.println("\n--< done\n");
58 }
59
60}
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