Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

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

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    10
    Thanks
    4
    Thanked 0 Times in 0 Posts

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

    Hey, im currently making a 3D modeling program in java (its for a game). And, everything was working fine until yesterday. Eclipse shows no errors, and this shouldn't be happening, but I get the
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
    I know what it means, but I cant seem to fix it. My code is too long to post here (1000+ lines), but heres the section that is causing the error -

    public static void main(String[] args)
    	{
     
    			new MCModeler(Integer.parseInt(args[0]));
    		}
    	}

    If you want to see the full code, just ask.

    Thanks


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

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

    It appears to me that your code is written to use the command line parameters, and you're calling it without passing in any command line parameters. As I see it you have two possible choices, maybe more:

    1. you could only call this program with command line parameters, or
    2. have the code check first to see if any command line parameters have been passed. If none have been passed then either exit or else do some default behavior.

  3. The Following User Says Thank You to curmudgeon For This Useful Post:

    maxattack (November 22nd, 2012)

  4. #3
    Junior Member
    Join Date
    Nov 2012
    Posts
    10
    Thanks
    4
    Thanked 0 Times in 0 Posts

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

    Ill try that, thanks

    --- Update ---

    Didn't seem to work, any other ideas?

  5. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

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

    Quote Originally Posted by maxattack View Post
    Ill try that, thanks

    --- Update ---

    Didn't seem to work, any other ideas?
    "didn't seem to work" tells us squat. You need to tell us and show us more. What did you try? What code changes have you made? What specific errors is this code causing?

Similar Threads

  1. Exception in thread "main" java.lang.NullPointerException problem.......
    By Adam802 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 20th, 2012, 02:23 AM
  2. Replies: 3
    Last Post: December 7th, 2011, 02:03 AM
  3. Replies: 6
    Last Post: November 12th, 2010, 04:40 AM
  4. Replies: 2
    Last Post: March 26th, 2010, 11:22 AM
  5. Replies: 1
    Last Post: October 25th, 2009, 11:54 AM