Reputation: 1843
I recently got this error:
chan@TakShing:~/Desktop/Java$ javac test.java
test.java:16: error: cannot find symbol
String encoded = Base64.encodeBase64String( user_pass.getBytes() );
^
symbol: variable Base64
location: class test
1 error
So I went around websites and found out that you have to download the source file which I have from: http://commons.apache.org/proper/commons-codec/download_codec.cgi
I downloaded "commons-codec-1.10-src.tar.gz" under "Source", but I am completely stuck on how to proceed with the final step of getting everything connected. I am currently on Ubuntu as well.
I admit that I have seen some posts saying to set the classpath, but I do not understand because all the answers I found were "set classapth" and that's it. The problem is I have no idea how to do that and I am a total amateur when it comes to doing this technical stuff and especially on Ubuntu. Can someone help me please?
Upvotes: 0
Views: 943
Reputation: 529
There's no need to download any packages or anything provided you already have the java JDK installed. You just forgot to import the Base64 package.
At the top of your document, write:
import java.util.Base64
and you should be fine and dandy.
I re-wrote your code to conform to Java's Base64 package.
import java.util.Base64;
String encoded = Base64.getEncoder().encodeToString(user_pass.getBytes());
Upvotes: 2