Java 包 org.apache.commons.lang 不存在 [Netbeans]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19381095/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
package org.apache.commons.lang does not exist [Netbeans]
提问by Mo Arctic
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:-
我是具有基本知识的编程新手,我将其与 Java 进行了比较。
我想编写一个代码,在不使用循环的情况下计算一个数的 n 次方。我一直在尝试使用大约 4 天前我了解到的“commons lang”中的重复方法。我在这个网站和其他网站上找到了很多信息,这些信息帮助我了解如何使用这个包装。
到目前为止,我下载了 commons-lang3-3.1,然后将该文件夹保存在与我的项目相同的文件夹中,并通过以下方式将 jar 文件添加到我的项目库中:-
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:
右键单击库
1 然后添加 JAR/文件夹
2 然后我打开了 commons-lang3-3.1 文件夹
3 并从 4 个选项中选择了“commons-lang3-3.1.jar”:
- commons-lang3-3.1.jar
- commons-lang3-3.1-javadoc.jar
- commons-lang3-3.1-sources.jar
- commons-lang3-3.1-tests.jar
- 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 symbolat line 6
How do I get a successfully import ?
第 1 行表示包 org.apache.commons.lang 不存在。
第 7 行说应该检查方法返回值
,如果我删除第 1 行,我会在第 6 行得到一个无法找到的符号
如何成功导入?
Screenshot of Netbeans:
Netbeans 截图:
采纳答案by predi
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;