473,416 Members | 1,836 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

how to handle this java.lang.ArrayIndexOutOfBoundsException

Expand|Select|Wrap|Line Numbers
  1. public class EmployeeServicesTestCase {
  2.  
  3.     /**
  4.      * @param args
  5.      */
  6.     public static void main(String[] s)throws Exception {
  7.         // TODO Auto-generated method stub
  8.         BeanFactory beans=new XmlBeanFactory(new ClassPathResource("applicationContext.xml"));
  9.         EmployeeService es=(EmployeeService)beans.getBean("employeeService");
  10.  
  11.         es.incrementSalary(Integer.parseInt(s[0]), 1000);
  12.  
  13.  
  14.     }
  15.  
  16. }
  17.  




Exception is:------
log4j:WARN No appenders could be found for logger (org.springframework.util.ClassUtils).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at com.shaik.spring.Test.EmployeeServicesTestCase.mai n(EmployeeServicesTestCase.java:22)
Sep 5 '10 #1
1 3697
Dheeraj Joshi
1,123 Expert 1GB
It looks like you are not passing anything in the command line argument.

To get the arguments you need to run your program as in the below example.

Expand|Select|Wrap|Line Numbers
  1. Java MyPrgm arg1 arg2 arg3 arg4
  2.  
Now in main you can loop through the command line argument array and get the arguments

Expand|Select|Wrap|Line Numbers
  1. public static void main(String args[])
  2. {
  3.     for (int i = 0; i < args.length; i++)
  4.       System.out.println(args[i]);
  5. }
  6.  
Check this for more information.

Regards
Dheeraj Joshi
Sep 6 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Lem | last post by:
I get the error Exception in thread "main" java.lang.NoClassDefFoundError when I type java app2 in the command prompt. I've tried moving to the jre directory and typed java c:\app2\app2, but it...
0
by: Shawn | last post by:
I am getting the following error with a Java Applet being served out by IIS over HTTPS/SSL using a Verisign certificate: java.lang.NoClassDefFoundError: javax/help/HelpSetException at...
1
by: greg.knaddison | last post by:
Hi, I'm trying to use the httpclient within Jython (see http://jakarta.apache.org/commons/httpclient/ for more information on the httpclient). My Jython version is: Jython 2.1 on...
1
by: CM | last post by:
Hi, when i want connect me in my BD with a JSP (with this simple code), this exception is throw. Thank's for ur help Mathieu CODE of my JSP ---------------------
6
by: ganesh.m | last post by:
Hi, I am new to DB2. I am getting this error while loading the DB2Driver. I don't have any idea about where i might have gone wrong. please help me. Below is the stack trace. Stack Trace:...
0
by: snkssa | last post by:
Hi, I got the following error while building an application with ant. please can you give the solution or reason why it is failing? Thank you create_zip_linux: ...
22
oll3i
by: oll3i | last post by:
i get Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 at Producent.main(producent.java:605) when i run it from bat @start "Supply Chain Management-Producer to...
6
by: Light | last post by:
Hi I m getting this error while i m trying to run my program and i don't understand why that happens. import java.util.*; public class Exercise6 {
2
by: cloudy | last post by:
First at all, i'm sorry, i not good in writing english. i want to retrieve a string from my applet via Javascript. I use a method named ReadAll. public String ReadAll(String StrOut, String...
4
by: jmitch89 | last post by:
I don't why I get this error: Exception in thread "main" java.lang.NoClassDefFoundError The statement below works just fine: java -cp...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.