简体   繁体   English

包org.apache.commons.lang不存在[Netbeans]

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

Am new to programming with basic knowledge and I've taken a liken to Java. 我是基础知识编程的新手,我已经习惯了Java。
I wanted to write a code that calculates a number to the nth power without using loops. 我想编写一个代码来计算第n次幂的数字而不使用循环。 I've been trying to use the repeat method from "commons lang" which i came to know about, about 4 days ago. 我一直在尝试使用大约4天前我所了解的“commons lang”中的重复方法。 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:- 到目前为止,我下载了commons-lang3-3.1,然后将文件夹保存在与我的项目相同的文件夹中,并将jar文件添加到我的项目库中:

right clicking on libraries 右键点击库
1 then Add JAR/Folder 1然后添加JAR /文件夹
2 then i opened the commons-lang3-3.1 folder 2然后我打开了commons-lang3-3.1文件夹
3 and selected "commons-lang3-3.1.jar" from a number of 4 selections: 3,从4个选项中选择“commons-lang3-3.1.jar”:

  • commons-lang3-3.1.jar 公地lang3-3.1.jar
    • commons-lang3-3.1-javadoc.jar 公地lang3-3.1-javadoc.jar
    • commons-lang3-3.1-sources.jar 公地lang3-3.1-sources.jar
    • commons-lang3-3.1-tests.jar 公地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 . 第1行说包org.apache.commons.lang不存在
line 7 says Should check the method return value 第7行说应检查方法返回值
and if i remove line 1 i get a cannot find symbol at line 6 如果我删除第1行,我会在第6行找不到符号
How do I get a successfully import ? 如何成功导入?

Screenshot of Netbeans: Netbeans的屏幕截图:

在此输入图像描述

http://commons.apache.org/proper/commons-lang/ states the following: http://commons.apache.org/proper/commons-lang/声明如下:

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. 需要注意的是郎3.0(以及后续版本)使用不同的包(org.apache.commons.lang3),比以前的版本(org.apache.commons.lang),允许它在同一时间较早的版本使用。

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...". 因此,相应地更改包装,或者留意Richard Tingle的建议,然后左键单击装订线中的错误+灯泡图标(显示行号)并选择“为...添加导入”。

import org.apache.commons.lang3.StringUtils;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM