Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why it is not working "CmdLineArgsApp.class"
#1
AOA Sir,

Here is the message when run the "java CmdLineArgsApp"

D:\java>java CmdLineArgsApp
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at CmdLineArgsApp.main(CmdLineArgsApp.java:7)

What is wrong with it?
Reply
#2
When while running CmdLineArgsApp you do not provide any command line arguments you get this exception.

Because in the code args[0] and args[1] are being used , if we do not provide any argument at command line, args[0] and args[1] do not have any value and exception is generated.

You can place a check to avoid this exception, you can check for number of element (i.e. check the value of args.length ) in args array if they are greater then 0 then proceed futher.

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error in Java can not find main class or can not find jvm.dll Xpert 0 1,161 06-24-2011, 07:50 AM
Last Post: Xpert
  Java Not Found or Not Working' occurs while playing Pogo games with Norton Internet Xpert 0 1,079 06-24-2011, 07:46 AM
Last Post: Xpert
  Java applet working or not on windows 7 Java 2011 Vuhelper 0 1,342 06-14-2011, 09:22 PM
Last Post: Vuhelper
  How static class variables get initialized Vuhelper 0 842 06-09-2011, 09:56 PM
Last Post: Vuhelper
  Class design question 2011 Vuhelper 0 1,860 06-04-2011, 10:43 PM
Last Post: Vuhelper
  Why getCountStudent() method is called using Class Name instead of first making new saneha 1 5,904 04-28-2011, 09:10 PM
Last Post: Vuhelper
  Java working High-performance for all platforms Xpert 0 1,898 04-28-2011, 04:17 AM
Last Post: Xpert
  AddressBookTest Class is giving error in java 2011 saneha 1 2,122 04-27-2011, 10:46 PM
Last Post: Vuhelper
  What does constructor do in class?Why we use copy constructor in class. Is it necessa saneha 1 2,438 04-24-2011, 06:40 PM
Last Post: Vuhelper
  Sir how can we make java ".class" file as .exe file. So that we could run it directly saneha 0 5,809 04-24-2011, 05:57 PM
Last Post: saneha

Forum Jump:


Users browsing this thread: 1 Guest(s)