在cmd中编译base64的错误

时间:2014-12-29 09:45:21

标签: java cmd base64

我正在尝试使用cmd编译applet,我收到以下错误:

Mc.java:1: error: package org.apache.commons.codec.binary does not exist
import org.apache.commons.codec.binary.Base64;
                                  ^
Mc.java:279: error: cannot find symbol
    byte[] accountKeyBytes = Base64.encodeBase64((accountKey + ":" + accountKey).getBytes());
                             ^
symbol:   variable Base64
location: class Mc
2 errors

知道如何解决问题吗?

使用jar文件编译后,我收到了错误:

 Exception in thread "AWT-EventQueue-1" java.lang.NoClassDefFoundError: org/apach
 e/commons/codec/binary/Base64
    at Mc.SearchApi(Mc.java:279)
    at Mc$ButtonHandler.keyPressed(Mc.java:172)
    at java.awt.Component.processKeyEvent(Component.java:6463)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2829)
    at java.awt.Component.processEvent(Component.java:6282)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1895)
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:762)
    at   java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1027)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeybo
    ardFocusManager.java:899)...

2 个答案:

答案 0 :(得分:1)

此错误是您的项目中缺少的库文件。 您只需要下载apache jar文件并将其设置为java类路径。

commons-codec-x.x.jar


如果你仍然怀疑jar文件设置为类路径,你可以找到以下链接。

Adding jar to classpath when running from command line
Including jars in classpath on commandline (javac or apt)

答案 1 :(得分:0)

视窗:

最新的JDK 1.8。版本

您可以添加jdk1.8.0_121 \ jre \ lib \ ext

它对我有用。我没有使用任何刚刚在记事本中编写并在命令提示符下编译的IDE。