简体   繁体   English

找不到符号,但是库已导入

[英]Symbol not found, but library is imported

I am using Netbeans and I am trying to use the base64 library, but it gives me "cannot find symbol" 我正在使用Netbeans,并且尝试使用base64库,但是它给了我“找不到符号”

OutputStream b64 = new Base64.OutputStream(os);

First I tried adding it like this 首先,我尝试像这样添加它

import org.apache.commons.codec.binary.Base64;

Which gives me a package does not exist, so I went to this website and downloaded the jar file. 这给了我一个不存在的软件包,所以我去了这个网站并下载了jar文件。 I downloaded for more than one website, but last one was http://www.java2s.com/Code/Jar/o/Downloadorgapachecommonscodecjar.htm 我下载了多个网站,但最后一个是http://www.java2s.com/Code/Jar/o/Downloadorgapachecommonscodecjar.htm

I added the library by right click on libraries, add Jar/Folder and selecting the .jar file that was downloaded. 我通过右键单击库,添加Jar /文件夹并选择已下载的.jar文件来添加库。 This gives me a package does not exist. 这给了我一个不存在的包。

Can someone explain to me why this happens. 有人可以向我解释为什么会这样。

Note: My goal is to use java robot to copy a part of the screen and send it as a post request. 注意:我的目标是使用Java机械手复制屏幕的一部分并将其作为发布请求发送。

Download the jar from Apache: http://commons.apache.org/codec/download_codec.cgi 从Apache下载jar: http//commons.apache.org/codec/download_codec.cgi

The desired package and class is available in the jar ie commons-codec-1.7.jar 所需的包和类可在jar中找到,即commons-codec-1.7.jar

    org.apache.commons.codec.binary.Base64

Add the above Jar from this distribution and let me know, if you still get the issue. 如果您仍然遇到问题,请从此发行版中添加上述Jar,让我知道。

Though I think, to get the output stream, you would want to use org.apache.commons.codec.binary.Base64OutputStream . 尽管我认为,要获得输出流,您可能需要使用org.apache.commons.codec.binary.Base64OutputStream

I believe you meant to use org.apache.commons.codec.binary.Base64OutputStream : 我相信你打算使用org.apache.commons.codec.binary.Base64OutputStream

OutputStream b64 = new Base64OutputStream(os);

This will require Apache's commons-codec.jar on your classpath. 这将需要在类路径上使用Apache的commons-codec.jar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM