Jump to content
Excelsior Forums
Sign in to follow this  
Qdex

java.lang.StringIndexOutOfBoundsException

Recommended Posts

Hi there,

I've just upgraded to JET v4.8 Standard Edition, and I'm getting this error:

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String ind

ex out of range: -2

? ? ? ? at java.lang.Void.<unknown>(Unknown Source)

? ? ? ? at java.lang.Void.<unknown>(Unknown Source)

? ? ? ? at java.lang.Void.<unknown>(Unknown Source)

? ? ? ? at java.lang.Void.<unknown>(Unknown Source)

This is in the main() method and occurs at the point where my own program class is about to be called.? Now this only happens if I do a 'Trial Run' in JetPack II - if I run the main executable on my development machine there is no problem.

Any ideas?

Share this post


Link to post
Share on other sites

Hello.

What version of JET have you upgraded from?

Please enable the "-Djet.stack.trace" property. It shall help to see where the exception is thrown.

Share this post


Link to post
Share on other sites

Ok, I got the following extra information:

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String ind

ex out of range: -2

? ? ? ? at java.lang.String.<unknown>(Unknown Source)

? ? ? ? at com.xxx.CFRLocatorHome.MapManager.scanForMaps(Unknown Source)

? ? ? ? at com.xxx.CFRLocatorHome.MapManager.<init>(Unknown Source)

? ? ? ? at com.xxx.CFRLocatorHome.CFRLocator.<init>(Unknown Source)

? ? ? ? at com.xxx.CFRLocatorHome.CFRLocator.main(Unknown Source)

The scanForMaps() method is new in fact, and it looks for map files in the program directory, by first calling:

File[] children = dir.listFiles();

then parsing filenames... I'm confused now as the method should either work all of the time, or not at all. I'll attempt to debug myself for the moment, then get back to you as the problem may well be mine.

Thanks

Share this post


Link to post
Share on other sites

Ok, I'm embarrassed - that'll teach me to change two things at once (JET version and addition of new method)!!

I've now placed appropriate try/catch statements in the method as some filename lengths were short and this causes String indexes to go negative

Thanks for the quick response and also the information on the stack trace command, as this quickly allowed me to home in on the problem.

JET continues to perform extremely well!

Cheers

Gary

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×