java 为什么我不能导入 org.apache.commons.lang.StringUtils?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25193837/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 07:33:16  来源:igfitidea点击:

How come I can't import org.apache.commons.lang.StringUtils?

javaclasspath

提问by user3435009

enter image description here

在此处输入图片说明

I added the common lang jar file in the classpath, but when I compile it says:

我在类路径中添加了 common lang jar 文件,但是当我编译它时说:

error: package org.apache.commons.lang does not exist

错误:包 org.apache.commons.lang 不存在

I tried to follow the steps described below:

我尝试按照下面描述的步骤操作:

http://oopbook.com/java-classpath-2/classpath-in-jcreator/

http://oopbook.com/java-classpath-2/classpath-in-jcreator/

but I don't it doesn't work. Is it the editor that's not working properly or is it something else?

但我不知道这是行不通的。是编辑器工作不正常还是其他原因?

回答by azurefrog

Between major versions 2 and 3 apache changed the package naming scheme on their classes from langto lang3.

在主要版本 2 和 3 之间,apache 将其类的包命名方案从lang更改为lang3

Notice on the download site that for version 2.6 you are downloading "commons-lang-2.6" and for version 3.3.2 you are downloading "commons-lang3-3.3.2".

请注意,在下载站点上,对于 2.6 版,您正在下载“commons- lang-2.6”,对于 3.3.2 版,您正在下载“commons- lang3-3.3.2”。

Also, if you check out the current API docyou'll see the new naming structure.

此外,如果您查看当前的 API 文档,您将看到新的命名结构。

All you need to do is update your import statement to match the new package structure and your compiler will be able resolve it correctly.

您需要做的就是更新您的导入语句以匹配新的包结构,您的编译器将能够正确解析它。