Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2009
    Posts
    3
    Rep Power
    0

    Default Is the imported package foo beeing used in the programm

    Is there any way to knwo, if an imported package ist beeing used in the java-program or not?

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    5

    Default

    Each .java file has its own set of imports.

    So you could use a simple text editor to search the java file containing the import for that class that was imported.

    Some IDE tools like eclipse offer helpful hints when an import is not in use and can be safely removed.

    Extra unused imports don't affect the compiled class behavior, just possibly make it more difficult to compile a class. For example, if you import a class that exists in a third party .jar file and this jar file is not in the classpath, and if the class imported is not even used by the .java file, then it will not compile unless we add the .jar file to the class path, or remove the unused import.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,310
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by cthulhufhtagn View Post
    Is there any way to knwo, if an imported package ist beeing used in the java-program or not?
    Comment out the corresponding import statement(s) and compile your sources and see for yourself.

    kind regards,

    Jos

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    In tricky way, if you know the exact package location of foo, temporary remove it from that location and compile your source again. If you are using an IDE easily you can find all the reference locations within your source code.

Similar Threads

  1. Replies: 7
    Last Post: 11-09-2009, 07:51 AM
  2. [SOLVED] my programm doesn´t run like it shoud be.
    By AlejandroPe in forum New To Java
    Replies: 3
    Last Post: 04-07-2009, 12:42 PM
  3. web programm (.jsp)
    By renars1985 in forum New To Java
    Replies: 1
    Last Post: 12-18-2007, 03:23 PM
  4. web programm (.jsp)
    By renars1985 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 12-18-2007, 08:34 AM
  5. Programm Error: cannot find symbol Help?
    By junix in forum New To Java
    Replies: 2
    Last Post: 12-10-2007, 05:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •