我试图运行使用此library的示例pcsc项目。
运行时我收到以下错误
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$1.run(Unknown Source)
at java.net.URLClassLoader$1.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&amp; commons-lang3-3.1-sources.jar in libs和类路径也。我仍然收到此错误
代码
public static void main(final String[] args) throws CardException, CommunicationException {
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
请帮忙!
答案 0 :(得分:17)
我添加了commons-lang-2.6.jar&amp;公地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
。
答案 1 :(得分:6)
如果您正在使用 Maven 将此内容放入pom.xml:
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
Apache Commons Lang™依赖信息 - 最新版本3.8(发布日期:2018年8月20日)
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8</version>
</dependency>
compile 'org.apache.commons:commons-lang3:3.8'
'org.apache.commons:commons-lang3:jar:3.8'
<dependency org="org.apache.commons" name="commons-lang3" rev="3.8">
<artifact name="commons-lang3" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.apache.commons', module='commons-lang3', version='3.8')
)
libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.8
[org.apache.commons/commons-lang3 "3.8"]
https://commons.apache.org/proper/commons-lang/dependency-info.html
答案 2 :(得分:2)
Yo添加了以下内容并更新了maven pronject就像一个魅力
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
答案 3 :(得分:0)
当其他一切都正确时,很少有jar文件被破坏。确保在编译时不会看到类似下面的错误
[ERROR] error reading
C:\Users\Mohan\.m2\repository\org\apache\commons\commons-lang3\3.7\commons-lang3-3.7.jar;
ZipFile invalid LOC header (bad signature)
答案 4 :(得分:0)
答案 5 :(得分:0)
添加以下内容对我有用
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>