Skip to main content

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0

2 replies [Last post]
ajayyaduwanshi
Offline
Joined: 2007-10-11
Points: 0

Hi All
I am getting this error Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at com.pbx.main.PBXMain.main(PBXMain.java:63)
in the following
package com.pbx.main;

import java.net.*;
import java.io.*;
import com.pbx.core.*;
import java.util.*;

public class PBXMain {

/**
* Properties file
*/
private static final String CONFIG_BUNDLE_NAME = "properties.ApplicationConfigurations";

/**
* Properties file
*/
private static final String CONFIG_BUNDLE_NAME2 = "properties.PBXLogging";

/**
* For holding the PropertyResourceBundle
*/
private static PropertyResourceBundle configBundle;

static {
try {
configBundle = (PropertyResourceBundle) PropertyResourceBundle.
getBundle(CONFIG_BUNDLE_NAME);

} catch (Exception ex) {
}
}

/**
* jarFilePath
*/
private static String jarFilePath = configBundle.getString("800PBXLIB");

public PBXMain() {

}

public static void main(String[] args) {
PBXMain pbxmain = new PBXMain();

Call call =null;

int startint = args[0].indexOf("/");

String jarFile = args[0].trim() + ".jar";

int endint = args[0].indexOf("_");

args[0] = args[0].substring(startint + 1, endint);

String mainClass = args[0].trim();

String iDNum =args[1].trim();

String itemID =args[2].trim();

String pinNO =args[3].trim();

String pinNO1 =args[4].trim();

String pinNO2 =args[5].trim();

String pinNO3 =args[6].trim();

try {
// Load all classes from jar file without giving classpath
URL url = new URL("jar:file:" + jarFilePath + "/" + jarFile + "!/");

JarURLConnection jarConnection = (JarURLConnection) url.openConnection();

URL[] urls = new URL[] {url};

ClassLoader classLoader = new URLClassLoader(urls);

CallHandler callobject =(CallHandler) (classLoader.loadClass(mainClass).newInstance());

try{ call = new Call();

} catch (Exception ex){

ex.printStackTrace();
}

try{
callobject.answerCall(call,iDNum,itemID,pinNO,pinNO1,pinNO2,pinNO3);
} catch (Exception ex){

ex.printStackTrace();
}

} catch (InstantiationException ie) {
ie.printStackTrace();
/*

( "Raised InstantiationException while reading protocol. " +
ie.getMessage());
*/

} catch (ClassCastException cce) {
cce.printStackTrace();

/*
( "Raised ClassCastException while reading protocol. " +
cce.getMessage());
*/

} catch (ClassNotFoundException cnfe) {
cnfe.printStackTrace();

/* ("Raised ClassNotFoundException while reading protocol. " +
cnfe.getMessage());
*/
}

catch (FileNotFoundException fe) {
fe.printStackTrace();

/* ("Raised FileNotFoundException while reading protocol. " +
fe.getMessage());
*/

} catch (SecurityException se) {
se.printStackTrace();

/* ("Raised SecurityException while reading protocol. " +
se.getMessage());
*/

} catch (IOException ioe) {
ioe.printStackTrace();

/* ("Raised IOException while reading protocol. " +
ioe.getMessage());
*/

} catch (Exception e) {
e.printStackTrace();

/* ("Raised Exception while reading protocol. " +
e.getMessage());
*/
}

}
}
Please help me with this.

Thanks & Regards
Ajay Singh Yaduwanshi

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
gluk
Offline
Joined: 2009-04-20
Points: 0

The solution for most of the Java related errors can be found at this site: http://iderror.com/category/errors/java/

azlan95
Offline
Joined: 2003-09-17
Points: 0

you need to run your app as follows assuming your classpath is set:

java com.pbx.main.PBXMain -a bunch of options-

The exception is thrown because you left out -a bunch of options- in your command.

Azlan

Message was edited by: azlan95