Hi,
My main method starts like this:
------------------------------
public static void main(String[] args)
{
if (args.length > 1)
{
try
{
System.err.println("hello");
JFrame frame = new Task3(args); //doesn't like this bit
frame.pack();
-----------------------------------
Task3 function starts like this:
-----------------------------------
public Task3 (String[] imageFiles) throws IOException,
ImageDecoderException
{
super("Task1: Now comparing " + imageFiles[0] + " to other
images ...");
-----------------------------------
I hoped that the string values in args would be parsed into the array
imageFiles, but it doesn't seem to work. :-(
I've tried using argv.
Please could you tell me the problem. :-)
Thanks in advance,
Ess
Knute Johnson - 05 Apr 2005 18:12 GMT
> Hi,
>
[quoted text clipped - 33 lines]
> Thanks in advance,
> Ess
Well hope is a great virtue but it is not going to help you write
compilable Java code.
I would really like to help you with your problem but since you didn't
provide any compilable code or even any error messages (compile or
runtime) I have no idea what your problem could be but I will show you
one way to get your command line arguments into your code. The
arguments are an array of Strings. You will note that I am creating a
new instance of the class test4. If you want to pass the arguments to a
method and not a constructor the code would be different.
public class test4 {
public test4(String[] cmdLineStrs) {
for (int i=0; i<cmdLineStrs.length; i++)
System.out.println(cmdLineStrs[i]);
}
public static void main(String[] args) {
new test4(args);
}
}

Signature
Knute Johnson
email s/nospam/knute/
Ess - 06 Apr 2005 18:53 GMT
Hi,
Thank u for your replies. My problem wasn't with parsing argv, but
that I have other arrays being indexed at illegal locations!
Sorry for hassling u guys.
Have a good day,
Ess
> > Hi,
> >
[quoted text clipped - 55 lines]
> }
> }
Andy Flowers - 05 Apr 2005 18:15 GMT
> Hi,
>
[quoted text clipped - 6 lines]
>
> JFrame frame = new Task3(args); //doesn't like this bit
What is the error, I assume from your post it is a compile time error ? or
is it s runtime exception ?
Is Task3 a subclass of JFrame ?
Ess - 06 Apr 2005 00:01 GMT
Hi,
My error is a runtime one:
java.lang.ArrayIndexOutOfBoundsException: 2
I understand this has something to do with my array being too small,
but I can't see where the problem is.
Task3 is a subclass of JFrame. Here is some code of the program:
------------------------------------------------------
public class Task3 extends JFrame
{
//class variables
public Task3 (String[] imageFiles) throws IOException,
ImageDecoderException
{
super("Task1: Now comparing " + imageFiles[0] + " to other
images ...");
....
....
------------------------------------------------------
Than you again,
Ess
> > Hi,
> >
[quoted text clipped - 11 lines]
>
> Is Task3 a subclass of JFrame ?
Andy Flowers - 06 Apr 2005 07:52 GMT
> Hi,
>
> My error is a runtime one:
>
> java.lang.ArrayIndexOutOfBoundsException: 2
Your clue is in the number after the exception name '2'. This is the array
index you are attempting to access somewhere in your code and this is beyond
the end of the array.
In main you check if imageFiles[0] contains an element, do you do further
checks elsewhere ?
Perhaps you use imageFiles[2] elsewhere ?
Perhaps you could post a fuller example of your Task3(String[]...)
constructor ?