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 7939267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:03:07+00:00 2026-06-03T23:03:07+00:00

Is there a Sun command line parameter to provide warnings (or errors) in reference

  • 0

Is there a Sun command line parameter to provide warnings (or errors) in reference to unused import statements? The embedded eclipse javac compiler provides such warnings, but if the Sun / Oracle compiler has it as one of their -Xlint:XXX arguments, it is not well documented.

I’m looking to clean up an existing Java code base, which builds from the command line using Ant, and I would like integrate tracking and reporting of such statements into the nightly builds.

Some have suggested that imports have no effect on the compilation process, however looking at the compiler operations (with the -verbose flag) indicates that the compiler loads the imported classes unconditionally, even if they are not used in the written output. So, removing unused imports seems to have more benefits than just code comprehension at a glance.

  • 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-03T23:03:08+00:00Added an answer on June 3, 2026 at 11:03 pm

    Use checkstyle, and configure the UnusedImports module to be used (or pick a default configuration that already uses it).

    Checkstyle defines an unused import as:

    1. An non-wildcard import that is not referenced in the file.
    2. An import that is a duplicate of another import.
    3. An import from the java.lang package.
    4. An import from the same package as the class.
    5. (Optionally) an import that is only needed to resolve a JavaDoc link.

    In practice, it creates a report that java.awt.Component is not used (along with the line number).

    import java.awt.Component;
    class FooBar {
        ...
    }
    

    It does have some limitations, in the sense it can be confused by members with the same name as an import; but, this failure rarely finds it’s way into practice for most developers.

    From the documentation as to the limitation

    import java.awt.Component;
    class FooBar {
        private Object Component; // IMHO bad practice
        ...
    }
    

    Would not flag Component as unused.

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

Sidebar

Related Questions

Is there a simple recipe or library for creating a subcommand command line utility
In Rational Software's Clearcase, is there a cleartool subcommand, or other command line tool,
Is there an easy way to convert date and time like this: Sun, 14
I understand that there is a setting in Sun JVM for dumping the heap
Is there a java library or framework (other than the javax.comm provided by Sun)
If I recall correctly, there where at least to desktop programas from sun which
a = new Date(); Sun Apr 08 2012 16:58:03 GMT+0530 (IST) Is there any
There are many conflicting statements around. What is the best way to get the
I have written a command-line tool that uses sub-commands much like Mercurial, Git, Subversion
i use the command line in windows to compile and then execute my java

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.