Are you checking if the command length is at least 1? If not, the code is basically saying: You: If the first argument is equal to "hub" Code: How do I know what the first argument is? Nothing was specified. So basically, it's telling you that you're trying to access an argument that isn't there, hence why it throws an ArrayIndexOutOfBoundsException. The description of an ArrayIndexOutOfBoundsException from the Oracle documents: Thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal to the size of the array. Your issue described right there. You're trying to access an index index that isn't the size of your arguments.