Results 1 to 3 of 3
  1. #1
    pavel is offline Member
    Join Date
    Oct 2010
    Posts
    13
    Rep Power
    0

    Unhappy mistake The import com.vmware.vim25.CustomFieldDef is never used

    Hi, everyone.
    I want to make this program with java eclipse. But it is coming all the time mistake :confused: :
    The import com.vmware.vim25.CustomFieldDef is never used
    The import com.vmware.vim25.Permission is never used
    The method waitForMe() from the type Task is deprecated
    The method waitForMe() from the type Task is deprecated
    The method waitForMe() from the type Task is deprecated
    The method waitForMe() from the type Task is deprecated

    Is it form the library? In Google I can't get answer. I will be happy if someone can give some explanation.
    This is the source code:

    Java Code:
    package com.vmware.vim25.co.samples;
    
    import java.net.URL;
    import com.vmware.vim25.CustomFieldDef;
    import com.vmware.vim25.Permission;
    import com.vmware.vim25.mo.Folder;
    import com.vmware.vim25.mo.InventoryNavigator;
    import com.vmware.vim25.mo.ServiceInstance;
    import com.vmware.vim25.mo.Task;
    import com.vmware.vim25.mo.VirtualMachine;  
    
    /**
    * [color="blue"]VMware Infrastructure (vSphere) Java API[/color]
    * @author Steve Jin / Modified by Michael Hopf
    */  
    
    public class VMpowerOps  {   
    
    public static void main(String[] args) throws Exception    {           
    
    String vmname = "Test_VM";
    /* other ops: reboot|poweron|poweroff|reset|standby|suspend|shutdown */
    String op = "standby";     
    
    ServiceInstance si = new ServiceInstance(new URL("https://server1.fireline.de/sdk"), "root", "password", true);
    Folder rootFolder = si.getRootFolder();
    
    VirtualMachine vm = (VirtualMachine) new InventoryNavigator(rootFolder).searchManagedEntity("VirtualMachine", vmname);
    
       if(vm==null)
        {
          System.out.println("No VM " + vmname + " found");
          si.getServerConnection().logout();
          return;
        }
    
        if("reboot".equalsIgnoreCase(op))
        {
          vm.rebootGuest();
          System.out.println(vmname + " guest OS rebooted");
        }
        else if("poweron".equalsIgnoreCase(op))
        {
          Task task = vm.powerOnVM_Task(null);
          if(task.waitForMe()==Task.SUCCESS)
          {
            System.out.println(vmname + " powered on");
          }
        }
        else if("poweroff".equalsIgnoreCase(op))
        {
          Task task = vm.powerOffVM_Task();
          if(task.waitForMe()==Task.SUCCESS)
          {
            System.out.println(vmname + " powered off");
          }
        }
        else if("reset".equalsIgnoreCase(op))
        {
          Task task = vm.resetVM_Task();
          if(task.waitForMe()==Task.SUCCESS)
          {
            System.out.println(vmname + " reset");
          }
        }
        else if("standby".equalsIgnoreCase(op))
        {
          vm.standbyGuest();
          System.out.println(vmname + " guest OS stoodby");
        }
        else if("suspend".equalsIgnoreCase(op))
        {
          Task task = vm.suspendVM_Task();
          if(task.waitForMe()==Task.SUCCESS)
          {
            System.out.println(vmname + " suspended");
          }
        }
        else if("shutdown".equalsIgnoreCase(op))
        {
          Task task = vm.suspendVM_Task();
          if(task.waitForMe()==Task.SUCCESS)
          {
            System.out.println(vmname + " suspended");
          }
        }
        else
        {
          System.out.println("Invalid operation. Exiting...");
        }
        si.getServerConnection().logout();
      }
    }
    Last edited by Fubarable; 10-14-2010 at 04:05 PM. Reason: Moderator Edit: Code tags added

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,679
    Blog Entries
    7
    Rep Power
    21

    Default

    Eclipse can organize your imports (it removes the imports that aren't used and adds the imports your class needs) by pressing Ctrl-Shift-O (that's a capital Oh). See what happens.

    kind regards,

    Jos

  3. #3
    pavel is offline Member
    Join Date
    Oct 2010
    Posts
    13
    Rep Power
    0

    Default

    Thank you JosAH.
    The imports are away.
    But what I can find for this waitForMe method... Should I search some alternative method. Or other library? I don't undestand how is going really with methods and library.

Similar Threads

  1. Replies: 11
    Last Post: 05-18-2010, 02:49 PM
  2. i can't see the mistake
    By PVL268 in forum New To Java
    Replies: 3
    Last Post: 04-29-2009, 06:26 AM
  3. i can't see the mistake
    By PVL268 in forum New To Java
    Replies: 2
    Last Post: 04-28-2009, 07:30 AM
  4. PLEASE!!!help me to find mistake
    By sasha20 in forum New To Java
    Replies: 1
    Last Post: 01-11-2008, 11:50 AM
  5. Newbie can't spot his mistake :(
    By naxalyte in forum New To Java
    Replies: 4
    Last Post: 11-21-2007, 08:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •