views:

390

answers:

2

I am using Pulse - the Plugin Manager for Eclipse and installed. I have the Eclipse 3.5 for mobile development(Pulsar) profile with a couple other profiles.

I realized that the split() method called on a string from code such as below:

String data = "one, two, three, four";
data.split(",");

generates the error: "The method split(String) is undefined for the type String". I am aware that the split() method did not exist before Java's JRE 1.4 and perhaps could be the cause of the problem. The problem is I don't think I have jre/sdk versions installed. Perhaps there's one in-built with the Pulsar profile and needs editing - but I couldn't tell what settings (and where) needs tweaking. I have checked Windows>Preferences>Java>Installed JREs and it's set to >= jre1.4. Please help thanks.

+1  A: 

Last time I looked (in a Windows XP installation), I found the default installed JVM to be 1.3 .

You could pop open a "DOS shell" (err, command prompt) and type java -version to see the truth at least about whatever Java is on the PATH.

I would definitely recommend installing an up-to-date JDK. The JDK includes a compiler and other tools, that's more useful to a developer than just a JRE. You then need to go back into Eclipse's preferences and point its JDK/JRE settings at your newly installed JDK.

Carl Smotricz
I have already checked the java version using the command line and the result is 1.6.0_19. Neither does the PATH command return any info regarding the a jre/jdk of a version < 1.6..
pi
Strange. My next recommendation would be to write and run a tiny program in Eclipse that prints out `System.getProperty("java.vm.version")` and related info, e.g. `"java.home"`. For property names see http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getProperties() .
Carl Smotricz
A: 

I note "Eclipse 3.5 for mobile development". Maybe this tool expects to run J2ME, which I believe is several issues behind J2SE.

This page gives links to the JavaDoc for the various APIs in JME. There are several versions, (follow the links under CLDC and CDC and look for java.lang.String) but as far as I can tell none of them define String.split().

DJClayworth
I am aware that j2me lacks a range of features available on j2se and while that is possibility here, it may not be easy to verify (or is it?). Also, String methods are more basic than others such as XML/SOAP functions available on the J2ME platform. Any other ideas?
pi
I suppose that settles it. Strangely, the String class in JME is without the split() method according to JSR 118 - http://java.sun.com/javame/reference/apis/jsr118/. Thanks
pi
http://stackoverflow.com/questions/657627/split-string-logic-in-j2me
pi