Exception in thread "main" java.lang.NoSuchMethodError

B

BK

Hello!
I am using the split method to tokenize a string instead of the
StringTokenizer method. The program compiles without any problem.
When executing it is giving the error:

Exception in thread "main" java.lang.NoSuchMethodError
at Test2.main(Test2.java:11)

I would really appreciate it if someone can help me fix this error.

This is the program that I am executing:

import java.io.*;
import java.util.*;

class Test2
{
public static void main(String[] args)
{
try
{
String s = "A B C DE FGH";
String[] result = s.split("\\s");
for (int i=0; i<result.length ; i++)
{
System.out.println(result);
}
//StringTokenizer result = new StringTokenizer("10:27A 04/06
09664 **");
//while (result.hasMoreTokens()) {
//System.out.println(result.nextToken());
//}

}
catch (Exception e)
{
}



}
}

Thanks
 
A

Arnaud Berger

Hi,

Are you using the same version of java (JDK/JRE) for executing as the
version you use for compiling ?
It seems that the method was found at compile time, but not at run time.

Regards,

Arnaud
 
B

BK

Yes I am using the same version, I am compiling it which completes
successfully and immediately trying to execute it using java Test2.
This gives the error.
 
C

castillo.bryan

add System.out.println(System.getProperty("java.version"));
to your code and post what it prints out. I'm 99% sure that the
version will be below 1.4.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top