1

I am trying to compile an applet using cmd and I get the following error:

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

Any idea how to solve the problem?

After the compile with jar files I get that error:

 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)...
user4371974
  • 13
  • 1
  • 6

2 Answers2

1

This error is library file missing in your porject. You just need to download apache jar file and set it into your java class path.

commons-codec-x.x.jar


If you still doubt at jar file set into class path, you can find out with below links.

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

Community
  • 1
  • 1
Ye Win
  • 2,020
  • 14
  • 21
  • Yes, I have download the commons-codec-1.10.jar but I get this error again – user4371974 Dec 29 '14 at 10:00
  • correctly set its to class path?? and compile time is still error?? – Ye Win Dec 29 '14 at 10:04
  • I compile with this command:javac -g -cp commons-codec-1.10.jar;jsoup-1.8.1.jar Mc.java but it is applet and I used the appletviewer Mc.html to run it. Is it correct? – user4371974 Dec 29 '14 at 10:08
  • Why you don't use some IDE for compile and run.It's more easy and great.I would recommend you to use Eclipse IDE. – Ye Win Dec 29 '14 at 10:09
  • In the compilers run perfectly but I want to include this applet in web application so I need to run in cmd as well. – user4371974 Dec 29 '14 at 10:11
  • After add library, your error is still same your title question.?Can you provide your full source code for more help?? – Ye Win Dec 29 '14 at 10:14
  • Sorry I get the error again for the libraries I will post piece of code for more help – user4371974 Dec 29 '14 at 10:24
  • can you look the code above and the error message. I will appreciate! – user4371974 Dec 29 '14 at 10:29
  • your error is can't find your commons-code.xxx.jar file from your main class.You should try first how to set jar file to classpath from command line.Because this additional answer should not post under your topic I think. – Ye Win Dec 29 '14 at 10:35
0

Windows:

For the latest JDK 1.8. version

You can add the jdk1.8.0_121\jre\lib\ext

It worked for me. I didn't use any IDE just wrote in notepad and compiled in command prompt.