Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java netbeans commadline argument passing

I am passing a command line argument using Netbeans but I get an ArrayIndexOutOfBoundsException.

My code is:

public class CmdLineArgumentPassing

{

      public static void main(String args[])
      {        
         System.out.println("Count : " + args.length);

         System.out.println("i : "+args[0]);
      }
} 

The output is:

Count : 0

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
like image 913
Samurai Avatar asked Apr 30 '26 17:04

Samurai


1 Answers

Right mouse click on the project, select Properties, go to the Run page, add the command line arguments.

like image 79
TofuBeer Avatar answered May 03 '26 05:05

TofuBeer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!