4

I have downloaded "commons-lang-2.6.jar" and added to my java project but I can't use StringUtils. Is there another jar file I should download or I have to change something in the project structure?

masoud
  • 55,379
  • 16
  • 141
  • 208
AliBZ
  • 4,039
  • 12
  • 45
  • 67
  • R u getting any error? what is the exact issue when you say "But I can't use StringUtils"? – SRy Feb 25 '13 at 22:27
  • The error is "Cannot resolve symbol “StringUtils”" – AliBZ Feb 25 '13 at 22:28
  • What IDE? And did you just setup your jdk? – Jane Doh Feb 25 '13 at 22:28
  • its intellij idea 12 CE, it works on windows with intellij idea 11.1 CE but not in mac. The thing is I import "com.sun.deploy.util.StringUtils" in windows and works, but in mac it doesn't work – AliBZ Feb 25 '13 at 22:30
  • Are you able to import other java classes on your mac? You may need to set the path for your jre? – Jane Doh Feb 25 '13 at 22:33
  • yes, I fixed the problem but still don't know why it works on windows and not on mac. funny thing is in windows, I didn't even import anything and "com.sun.deploy.util.StringUtils" works, but in mac I have to import the apache commons. – AliBZ Feb 25 '13 at 22:34
  • Weird, did Ctrl+Alt+S try to import anything? – Jane Doh Feb 25 '13 at 22:35
  • File menu > Settings > Code Style > Java > Imports – Jane Doh Feb 25 '13 at 22:39
  • I am not able to find any `stringUtils` in http://javasourcecode.org/html/open-source/jdk/jdk-6u23/com/sun/deploy/util/ package. Are you sure "stringUtils" you are mentioning is from this import only. – SRy Feb 25 '13 at 22:41
  • @Srinivas yes, when I comment it out, it gives me an error. – AliBZ Feb 28 '13 at 01:50

1 Answers1

3

You need to import the org.apache.commons.lang package.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • Thanx but it doesn't have StringUtils. – AliBZ Feb 25 '13 at 22:26
  • I have this code running using import com.sun.deploy.util.StringUtils in another machine but here it doesn't work. – AliBZ Feb 25 '13 at 22:28
  • 2
    As of latest versions of Apache Commons Lang, the [correct package](http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/org/apache/commons/lang3/StringUtils.html) is `org.apache.commons.lang3`. – Jonik Nov 20 '13 at 00:07