1. I have three classes
- Launcher........... (which launches 1 Parallel_Thread thread and 1 Shared Object)
- Parallel_thread.. (which talks twice to the shared object and then terminates)
- SharedObject.....(which runs until it is shut-down by the launcher class)
2. All Classes "javac" without any errors!
3. This is the Launcher Code
When running the launcher.class via java launcher<enter> from the commandline, this is the error that appears
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at Launcher.main(Launcher.java:57)
Now my questions about this message? 1. How is it possible to get an ArrayIndexOutOfBoundsException error?
I do not enter any commandline arguments when starting this class, so the Args array is not being used.
2. How is it possible to get an error in LINE 57, while my Launcher.java sourcecode is only 33 lines???
This is really weird to me :~}
The error message you posted was thrown from line 57 of the Launcher class, in the main() method. But the code you posted for the Launcher class doesn't even have 57 lines. So the code you posted isn't the code which threw that exception. Fix that problem first.
Ulf Dittmer wrote:I concur with Paul's post: you're not running the code that you think you're running. When I compile and run the code I get this output:
THAT is the result i was searching for too Ulf! Thanks for the feedback and from running it on your own system.
UPDATE for all 1. I have searched my entire harddisk(s) and found NO second copy of Launcher.java and Launcher.class (not even in hidden directories, "recycle bin" or "Trash/files" directories.
2. I have removed all .class files from the working directory and recompiled the 3 sourcecodes again -> Same error!
3. Finally i found a "solution:"
- I renamed - the Launcher class to Ronald class (in line 1 of the Launcher.java file)
- I renamed - the file Launcher.java to Ronald.java
- I recompiled this Ronald.java example ..... en voila... error gone :-) so this problem is solved
4. It still keeps wondering/bugging me how it was possible that this error occurred? An error inline 57 of a 34 line sourecode.
Questions A - Is it possible that there is was another Launcher.java, Lancher.class file on my system -> No rule out that one by a disk search.
B - Does the JAVAC compiler itself store any old compilation results (class files) for possible re-use? or faster re-compilation
C - When I enter Javac <filename.java> HOW does JAVAC find the filename.java:
----- Does JAVAC search in the current directory first?
----- Does JAVAC search along the PATH of the computer it runs on?
----- Option 3?
Thank you all for your valuable feedback and explanation on this "error".