首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >不能导入jar?

不能导入jar?
EN

Stack Overflow用户
提问于 2011-09-15 18:47:24
回答 3查看 9.2K关注 0票数 3

你好,有人能帮我解决这个简单的问题吗?我已经在一个java聊天网站上询问了8多位专家,但似乎没有人能帮到我。我已经从http://pdfbox.apache.org/download.html下载了jar文件。我已经打开了blueJ IDE并加载了jars。当我打字时

代码语言:javascript
运行
复制
import org.apache.pdfbox.*; 
import org.apache.pdfbox.pdmodel; 
import org.apache.pdfbox.pdmodel.PDPage; 

我收到一条错误消息:

代码语言:javascript
运行
复制
error has occured cannot find org.apache.pdfbox

我也尝试过netbeans,并使用了项目属性并添加了jar,我还访问了netbeans上的侧菜单,并尝试了这种方法。我还是会犯同样的错误。有人能帮忙吗?我在3台不同的电脑上试过这个。

好的,伙计们,给我更多信息。我下载了这些jar,并将它们放在blueJ中的一个文件夹中,我选择了选项,并选择了他们所说的“加载”的jar文件。我在Netbeans中也做了同样的工作,我已经向IDE展示了Jars所在的地方--它仍然不能工作--这是完整的代码,它只是从我正在尝试的PDFBOX网站上获取的示例代码。

代码语言:javascript
运行
复制
import org.apache.pdfbox.exceptions.*;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;

/**
 * This will create a blank PDF and write the contents to a file.
  */
public class CreateBlankPDF
{

/**
 * This will create a blank PDF and write the contents to a file.
 *
 * @param file The name of the file to write to.
 *
 * @throws IOException If there is an error writing the data.
 * @throws COSVisitorException If there is an error while generating the document.
 */
public void create( String file ) throws IOException, COSVisitorException
{
    PDDocument document = null;
    try
    {
        document = new PDDocument();
        //Every document requires at least one page, so we will add one
        //blank page.
        PDPage blankPage = new PDPage();
        document.addPage( blankPage );
        document.save( file );
    }
    finally
    {
        if( document != null )
        {
            document.close();
        }
    }
}

/**
 * This will create a blank document.
 *
 * @param args The command line arguments.
 *
 * @throws IOException If there is an error writing the document data.
 * @throws COSVisitorException If there is an error generating the data.
 */
public static void main( String[] args ) throws IOException, COSVisitorException
{
    if( args.length != 1 )
    {
        usage();
    }
    else
    {
        CreateBlankPDF creator = new CreateBlankPDF();
        creator.create( args[0] );
    }
}

/**
 * This will print the usage of this class.
 */
private static void usage()
{
    System.err.println( "usage: java org.apache.pdfbox.examples.pdmodel.CreateBlankPDF <outputfile.pdf>" );
}

}

EN

Stack Overflow用户

发布于 2011-09-15 18:51:35

下载这些jar文件后,你对它们做了什么?您是如何将它们添加到您的项目中的?Netbeans无法猜出罐子在你的电脑上的位置,这就是为什么当你进口的时候它不能工作.将jars添加到Netbeans项目:

假设jar文件在c:\下载中

使用netbeans中选择的项目,转到Properties->sources并选择Compile,然后将其添加到jars所在的位置。现在应该清除您的导入错误。

票数 0
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7435877

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档