NoClassDefFoundError: org/apache/commons/lang3/StringUtils
NoClassDefFoundError: org/apache/commons/lang3/StringUtils
我正在尝试 运行 使用 this 库的示例项目,但出现以下错误:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/commons/lang3/StringUtils
at com.github.devnied.emvnfccard.enums.EmvCardScheme.<init>(EmvCardScheme.java:97)
at com.github.devnied.emvnfccard.enums.EmvCardScheme.<clinit>(EmvCardScheme.java:32)
at com.github.devnied.emvnfccard.parser.EmvParser.readWithAID(EmvParser.java:277)
at com.github.devnied.emvnfccard.parser.EmvParser.readEmvCard(EmvParser.java:120)
at com.github.devnied.emvpcsccard.Main.main(Main.java:64)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
at java.net.URLClassLoader.run(Unknown Source)
at java.net.URLClassLoader.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 5 more
我添加了 commons-lang-2.6.jar & commons-lang3-3.1-sources.jar 在 libs 和 classpath
中
主要class:
public static void main(final String[] args) throws CardException {
Main pcsc = new Main();
CardTerminal ct = pcsc.selectCardTerminal();
Card c = null;
if (ct != null) {
c = pcsc.establishConnection(ct);
CardChannel channel = c.getBasicChannel();
PcscProvider provider = new PcscProvider(channel);
EmvParser parser = new EmvParser(provider, false);
parser.readEmvCard();
c.disconnect(false);
}
}
我参考了以下链接:
java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils from BaseClassLoader
Struts 2 framework demo
I have added commons-lang-2.6.jar & commons-lang3-3.1-sources.jar...
这是您的问题:commons-lang-2.6.jar
不包含 org.apache.commons.lang3
包,因为它是版本 3 的一部分,并且 commons-lang3-3.1-sources.jar
包含源代码,而不是字节码。
您需要包含 commons-lang3-3.1.jar
。
如果您正在使用 Maven,请将其放入您的 pom.xml
文件中:
Commons Lang 的 Maven 中央存储库:
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
Apache Commons Lang 的 Maven 中央存储库:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
Don't forget: Update Maven Project
Apache Commons Lang™ 依赖信息
上次发布时间:2020 年 8 月 30 日 |版本:3.11
Apache Maven
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
Apache 生成器
'org.apache.commons:commons-lang3:jar:3.11'
阿帕奇常春藤
<dependency org="org.apache.commons" name="commons-lang3" rev="3.11">
<artifact name="commons-lang3" type="jar" />
</dependency>
Groovy葡萄
@Grapes(
@Grab(group='org.apache.commons', module='commons-lang3', version='3.11')
)
Gradle/Grails
compile 'org.apache.commons:commons-lang3:3.11'
Scala SBT
libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.11"
莱宁根
[org.apache.commons/commons-lang3 "3.11"]
参考:
当其他一切都正确时,jar 文件很少会损坏。确保你在编译时没有看到类似下面的错误
[ERROR] error reading
C:\Users\Mohan\.m2\repository\org\apache\commons\commons-lang3.7\commons-lang3-3.7.jar;
ZipFile invalid LOC header (bad signature)
添加以下内容并更新 maven pronject 非常有效
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
我在更新到 2018.3.4 并在 Maven 选项选项卡上单击 "Generate sources and update folders for all projects" 后,我在 IJ 2016 版中遇到了这个问题,问题消失了
添加以下对我有用
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
我正在尝试 运行 使用 this 库的示例项目,但出现以下错误:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/commons/lang3/StringUtils
at com.github.devnied.emvnfccard.enums.EmvCardScheme.<init>(EmvCardScheme.java:97)
at com.github.devnied.emvnfccard.enums.EmvCardScheme.<clinit>(EmvCardScheme.java:32)
at com.github.devnied.emvnfccard.parser.EmvParser.readWithAID(EmvParser.java:277)
at com.github.devnied.emvnfccard.parser.EmvParser.readEmvCard(EmvParser.java:120)
at com.github.devnied.emvpcsccard.Main.main(Main.java:64)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
at java.net.URLClassLoader.run(Unknown Source)
at java.net.URLClassLoader.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 5 more
我添加了 commons-lang-2.6.jar & commons-lang3-3.1-sources.jar 在 libs 和 classpath
中主要class:
public static void main(final String[] args) throws CardException {
Main pcsc = new Main();
CardTerminal ct = pcsc.selectCardTerminal();
Card c = null;
if (ct != null) {
c = pcsc.establishConnection(ct);
CardChannel channel = c.getBasicChannel();
PcscProvider provider = new PcscProvider(channel);
EmvParser parser = new EmvParser(provider, false);
parser.readEmvCard();
c.disconnect(false);
}
}
我参考了以下链接:
java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils from BaseClassLoader
Struts 2 framework demo
I have added commons-lang-2.6.jar & commons-lang3-3.1-sources.jar...
这是您的问题:commons-lang-2.6.jar
不包含 org.apache.commons.lang3
包,因为它是版本 3 的一部分,并且 commons-lang3-3.1-sources.jar
包含源代码,而不是字节码。
您需要包含 commons-lang3-3.1.jar
。
如果您正在使用 Maven,请将其放入您的 pom.xml
文件中:
Commons Lang 的 Maven 中央存储库:
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
Apache Commons Lang 的 Maven 中央存储库:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
Don't forget: Update Maven Project
Apache Commons Lang™ 依赖信息
上次发布时间:2020 年 8 月 30 日 |版本:3.11
Apache Maven
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
Apache 生成器
'org.apache.commons:commons-lang3:jar:3.11'
阿帕奇常春藤
<dependency org="org.apache.commons" name="commons-lang3" rev="3.11">
<artifact name="commons-lang3" type="jar" />
</dependency>
Groovy葡萄
@Grapes(
@Grab(group='org.apache.commons', module='commons-lang3', version='3.11')
)
Gradle/Grails
compile 'org.apache.commons:commons-lang3:3.11'
Scala SBT
libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.11"
莱宁根
[org.apache.commons/commons-lang3 "3.11"]
参考:
当其他一切都正确时,jar 文件很少会损坏。确保你在编译时没有看到类似下面的错误
[ERROR] error reading
C:\Users\Mohan\.m2\repository\org\apache\commons\commons-lang3.7\commons-lang3-3.7.jar;
ZipFile invalid LOC header (bad signature)
添加以下内容并更新 maven pronject 非常有效
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
我在更新到 2018.3.4 并在 Maven 选项选项卡上单击 "Generate sources and update folders for all projects" 后,我在 IJ 2016 版中遇到了这个问题,问题消失了
添加以下对我有用
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>