Programming error

Discussion in 'OT Technology' started by illenvillen008, Nov 8, 2006.

  1. illenvillen008

    illenvillen008 New Member

    Joined:
    Jan 8, 2006
    Messages:
    205
    Likes Received:
    0
    I ahve been trying to set up an RMI client and when ever i run it i keep getting an error that says

    java.lang.arrayindexoutofboundsexception

    it referrences the line

    String name = ("//" + args[0] + "/MyServ");



    my code is as follows:

    import java.rmi.*;

    public class MyClient {

    public static void main(String args[]) {
    if(System.getSecurityManager()==null){
    System.setSecurityManager(new RMISecurityManager());
    }
    try{
    String name = ("//" + args[0] + "/MyServ");
    MyInterface stub = (MyInterface) Naming.lookup(name);
    Object res = stub.DoTask2();

    }catch (Exception e){
    System.err.println("MyServant exception" + e.getMessage());
    e.printStackTrace();
    }


    }
    }





    I was wonderring if anyone had anyideas as to Why this error keeps popping up and possibly how i'd fix it.
     
  2. rsxm5

    rsxm5 OT Supporter

    Joined:
    Oct 13, 2002
    Messages:
    2,961
    Likes Received:
    0
    Location:
    San Diego, CA
    Are you including an argument? For example when you run it, you say

    "java MyClient argument"
     
  3. Coottie

    Coottie BOOMER......SOONER OT Supporter

    Joined:
    Jun 6, 2006
    Messages:
    32,407
    Likes Received:
    0
    Location:
    OKC
    Are you calling your program and providing a parameter?? Like

    java <program_name> <parameter>

    You're accessing the 0th element of the args array but unlike C++ the program_name is not put into the 0th element.
     

Share This Page