aspose file tools*
The moose likes Beginning Java and the fly likes String.split() - new in 1.4.2? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String.split() - new in 1.4.2?" Watch "String.split() - new in 1.4.2?" New topic
Author

String.split() - new in 1.4.2?

andrew pierce
Ranch Hand

Joined: Jun 18, 2006
Posts: 33
I am working with Java 1.4.1. There doesn't appear to be a String.split() method. Was that introduced in 1.4.2?

I have used it quite exhaustively in 1.4.2 and 1.5.
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
The JDK Documentation for JDK 1.5 says in the "since tag" that it was implemented since version 1.4.

I checked Documentation for JDK 1.4.1 API Documentation and the method is described there.
andrew pierce
Ranch Hand

Joined: Jun 18, 2006
Posts: 33
Well that's interesting. The reason I thought this is because WSAD complains over the call the String.split(). I'm using WSAD 5.1.2. I assumed that it was using the 1.4.1 JDK.

Maybe I should move this thread over to the IBM/WebSphere area???

Compiling the same code from a command line with Java 1.5 works great. Why wouldn't WSAD like it?
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
Well, maybe you can check your WSAD environment and see what JDK you are using.

Perhaps you are using an older version.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
It could be there's a bug in the earliest 1.4 releases, but I couldn't find a report of it. Is it possible your path or class path is actually pointing to a JDK 1.3 or earlier? Can you see and use other 1.4 features like, say, java.util.regex.Pattern?


"I'm not back." - Bill Harding, Twister
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

WSAD allows you to choose which JRE is used to compile your classes. I have upgraded to RAD but I believe the menu options in WSAD were the same or similar: Window, Preferences, Java, Installed JREs.
andrew pierce
Ranch Hand

Joined: Jun 18, 2006
Posts: 33
When I look at the Installed JRE's, I see 8 in the list. The first one has a Name of "eclipse" and it's location is in:

C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\eclipse

There are several others like WebSphere v5.1 JRE, location: c:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1.2\runtimes\base_v51\java\jre

The first one has the check mark next to it. I tried changing it to another and it had no effect. I still got the errors in my project on a line of code like this:

String[] chunks = msg.split(",");

where msg is a String object.

Is there something I have to do to make it reevaluate the code in light of this change?

Also, the most recent item in that list is for WAS v5.1. Is there a way to update this list to include 5.1.1 (JDK 1.4.2)? Keeping in mind that WAS is actually on the server and not on my development box with WSAD.

I also have the Sun 1.5 JDK installed locally. Is it possible to add that JDK here and still target WAS with my EAR projects?

Thanks again.
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
Well, WSAD is based on Eclipse. Although you changed the list of installed JDK you still have to make the changes in your class path.

At least in my Eclipse environment (and I almost sure is the same in WSAD) you right click on the project root and choose Build Path->Configure Build Path.

There in the Libraries tab make sure that you are using the right JDK library. If not, remove the current library and add one of the new ones you just configured.

Does that help?
andrew pierce
Ranch Hand

Joined: Jun 18, 2006
Posts: 33
I finally resolved this problem. In testing, I created a simple "console" application with a main() method. I could use the String.split() method from this project. However, when working with an EJB project, the split method was unavailable and produced errors.

The steps to fix it were:

1. Select Window > Preferences > J2EE. Then select "Enable server targeting support"
2. Select Project > Properties > J2EE. From the Target server combo box, select WebSphere Application Server v5.1.

This caused the EJB project to use the 1.4 JRE and resolved all the String.split() calls.

Thanks for all the help with this issue.
Andrew
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String.split() - new in 1.4.2?