Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9182915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:40:39+00:00 2026-06-17T18:40:39+00:00

Forgive my confusion with Java imports — I come from a Python background. I

  • 0

Forgive my confusion with Java imports — I come from a Python background.

I have some code that makes use of the itext library:

public static void makeADoc (Person p, String outfile) throws DocumentException,FileNotFoundException{
        Document document = new Document;
        PdfWriter.getInstance(document, new FileOutputStream(outfile));
        document.open();
        document.add(new Paragraph("Hello " + p.getFirst() + ",\n" + "You've just won the lotto!"));
        document.close();
    }

I have added the applicable itext-pdf jar files to the project’s path. I have imported the entire library at the beginning of this class with a wildcard import statement:

import com.itextpdf.*;

Yet Eclipse is still giving me red underlined errors for Document objects and DocumentException and FileNotFound Exception objects. I am given the option to import the Document class from itextpdf, but it seems like my wildcard statement should have covered that. What’s going on?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:40:41+00:00Added an answer on June 17, 2026 at 6:40 pm

    The FileNotFoundException is not from the itextpdf package but from the package java.io. So you should also add this import statement. Keep also in mind that using such wildcards import statements is sometimes considered bad practice because it could clutter your namespace.

    Additionally, with your wildcard statement, you importing all the classes that are in the package com.itextpdf. However, the class DocumentException is in the package com.itextpdf.text and not com.itextpdf, so you would also have to add this import statement. Note that in Java there is no concept of sub packages, even though humans sometimes use this analogy. So com.itextpdf.text is a completely different package than com.itextpdf.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Forgive the title, wasn't sure what to put. I have some code like: var
Forgive me, I'm new to Java and have an extremely basic question. I have
(Updated due to some confusion over my question) We use this method to generate
Forgive me if this post is too naive-sounding. I have a Twitter app that
Forgive my ignorance. I'm a rookie trying to learn some programming. I have the
Forgive me for the upcoming question, lol. (Im terribly new at this) I have
Forgive me for this unbeautiful code, but I'm trying to get it to work
Forgive what might seem to some to be a very simple question, but I
I have a coldfusion cfc that i call to query events between the start
First off, please forgive the stupidness of this question but Im not from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.