File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Exception using split() method in java.lang.String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception using split() method in java.lang.String" Watch "Exception using split() method in java.lang.String" New topic
Author

Exception using split() method in java.lang.String

Uma Shwetha
Greenhorn

Joined: Feb 29, 2004
Posts: 2
Hi,
I get java.lang.NoSuchMethodError when using split(String) function in java.lang.String.
This is the code I used.
String str="1:2:3";
String arr[]=new String[10];
arr=str.split(":"); // gettting exception at this line
When I checked the syntax it seems to be exactly correct. Dont understand the reason for this error. Can anyone please help me out?
Thanks,
Uma.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

Hi,
Welcome to JavaRanch!
NoSuchMethodErrors happen when a method that was defined when you compiled your code isn't available when you run your code. This can happen when you compile with a newer JDK than you use at runtime.
The String.split() methods were introduced in JDK 1.4; so I imagine you're using a recent JDK to compile your code, and something older at runtime.
Either upgrade the runtime environment, or don't use the regexp stuff.


[Jess in Action][AskingGoodQuestions]
Uma Shwetha
Greenhorn

Joined: Feb 29, 2004
Posts: 2
Hi,
Thanks a lot for your reply.
You r right. I was having older version of JRE. I upgraded it. It worked.
Thanks,
Uma.
 
jQuery in Action, 2nd edition
 
subject: Exception using split() method in java.lang.String