Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

package org.apache.commons.lang does not exist [Netbeans]

Am new to programming with basic knowledge and I've taken a liken to Java.
I wanted to write a code that calculates a number to the nth power without using loops. I've been trying to use the repeat method from "commons lang" which i came to know about, about 4 days ago. I Found a lot of info in this site and others that helped me in understanding how to use this packed.
So far I downloaded commons-lang3-3.1 then kept the folder in the same folder as my project and added the jar file to my project's library by:-

right clicking on libraries
1 then Add JAR/Folder
2 then i opened the commons-lang3-3.1 folder
3 and selected "commons-lang3-3.1.jar" from a number of 4 selections:

  • commons-lang3-3.1.jar
    • commons-lang3-3.1-javadoc.jar
    • commons-lang3-3.1-sources.jar
    • commons-lang3-3.1-tests.jar

here is a code that am using to test that i got from one of the the other questions:-

0. package refreshingmemory;
1. import org.apache.commons.lang.StringUtils;
2. public class RefreshingMemory {
3.
4.     public static void main(String[] args) {
5.         String str = "abc";
6.         String repeated = StringUtils.repeat(str, 3);
7.         repeated.equals("abcabcabc");
8.
9.        }
10.    }

line 1 says package org.apache.commons.lang does not exist.
line 7 says Should check the method return value
and if i remove line 1 i get a cannot find symbol at line 6
How do I get a successfully import ?

Screenshot of Netbeans:

enter image description here

like image 864
Mo Arctic Avatar asked Oct 15 '13 12:10

Mo Arctic


1 Answers

http://commons.apache.org/proper/commons-lang/ states the following:

Note that Lang 3.0 (and subsequent versions) use a different package (org.apache.commons.lang3) than the previous versions (org.apache.commons.lang), allowing it to be used at the same time as an earlier version.

So change the package accordingly, or heed Richard Tingle's advice and left click the error+light bulb icon in the gutter (were line numbers are shown) and choose "Add import for...".

import org.apache.commons.lang3.StringUtils;
like image 196
predi Avatar answered Oct 12 '22 22:10

predi