Need help ->java.lang.ArrayIndexOutOfBoundsException: 0
Hi everybody
Can anyone help me on this error?
Thanks for any idea.
mySiti
publicstaticvoid main(String[] args)throws Exception{
Picture pic =new Picture(args[0]);
if (args.length != 1){
System.out.println ("Incorrect number of errors!");
System.exit(0);
pic.show();
}//end if
}// end main()
[762 byte] By [
mySitia] at [2007-10-2 22:05:51]

public static void main(String[] args) throws Exception {
Picture pic = new Picture(args[0]);
if (args.length != 1) {
System.out.println ("Incorrect number of errors!");
System.exit(0);
pic.show(); // this doesnt make any sense because of System.exit() above!
} //end if
}// end main()
How is the Picture class implemented? When I compiled and ran the code, I received no errors (I commented out the lines referring to pic of course).
Here's what I ran:
public class Test{
public static void main(String[] args) throws Exception {
//Picture pic = new Picture(args[0]);
if (args.length != 1) {
System.out.println ("Incorrect number of errors!");
System.exit(0);
//pic.show();
} //end if
}// end main()
}
try this:
public class Test{
public static void main(String[] args) throws Exception {
Picture pic = new Picture(args[0]);
if (args.length != 1) {
System.out.println ("Incorrect number of errors!");
System.exit(0);
} //end if
pic.show();
}// end main()
}
> try this:> ...> Picture pic = new Picture(args[0]);Um, and if there were no arguments, then that would cause the exception in question. Obviously you'd need to check the number of arguments *first*.
it may be better to post..that way, more than one person is working to solve the problem.if you can post, an example java file of your classes, the steps you took, and possibly where the error is occurring, that would help alot in finding a solution.how does this sound?
When I execute using JCreator, there error is ->java.lang.ArrayIndexOutOfBoundsException: 0But when using java Picture X.tif, there is no error.Whats different between them?Thanks for any idea.mySiti
issuing via java, you are passing in a parameter. you will probably need to do the same if you are running in JCreator. here's something on that idea on the JCreator site http://www.jcreator.com/faq.htm#30other than that, I do not know JCreator since I use eclipse.