Results 1 to 8 of 8
  1. #1
    Jessaurum is offline Member
    Join Date
    Oct 2009
    Posts
    6
    Rep Power
    0

    Default Error - "The import org.junit cannot be resolved"

    I am getting the error message of: "The import org.junit cannot be resolved".

    The lines of code that this refers to are:
    import static org.junit.Assert.*;
    import org.junit.Test;

    I'm currently using Windows Vista, and I'm using Eclipse 3.5 Galileo, which I'm led to believe comes bundled with JUnit 4.

    I'm not sure if that is enough information to help resolve the issue. Let me know if there's anything else you'd need to know.

    I had been using Eclipse on a school's computer, and had been able to have this particular program compile on it just fine before. It does not work on my recently installed version of Eclipse, although I have the same environment as I did at school. (Or at least I think I do.)

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

  3. #3
    Jessaurum is offline Member
    Join Date
    Oct 2009
    Posts
    6
    Rep Power
    0

    Default

    I'm not sure what you mean by import packages; is that different from the two lines of code that I posted in my message? If it is, how do I do this?

  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
    20

    Default

    Okay, I'll explain it in this way.

    First of all you've to attach the package (a jar file basically) in to your application first. That means you've to place your package in the correct place to access within your code. You can add it into your classpath. Or else you can do this through the IDE as well, in that case IDE do all the things for you, attaching into the correct place.

    Import statement is another thing, that's the way how you access the package.

    Is that clear to you?

  5. #5
    Jessaurum is offline Member
    Join Date
    Oct 2009
    Posts
    6
    Rep Power
    0

    Default

    Ok, I think I understand what you're saying. I'm not sure how to put this into practice though.

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

    Default

    You are using Eclipse, and there is an option to link external jar file into your project. Did you search on that?

  7. #7
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Right click your project, Build path->Configure build path->Libraries->Add Library and select JUnit.

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

Similar Threads

  1. Replies: 5
    Last Post: 04-02-2010, 04:01 PM
  2. Eclipse "import not resolved" package problem?
    By spamsickle in forum New To Java
    Replies: 3
    Last Post: 08-24-2009, 11:44 AM
  3. Replies: 2
    Last Post: 01-24-2009, 06:56 PM
  4. Replies: 1
    Last Post: 10-20-2008, 07:35 AM
  5. Dependencies "cannot be resolved"
    By Jesdisciple in forum Eclipse
    Replies: 0
    Last Post: 05-03-2008, 06:54 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
  •