Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting the build path in Eclipse

 
Tony Smith
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Eclipse 3.1.0

There is simply something I don't understand about build paths.

I have a project that works. However, I can no longer use IntelliJ. So I switched to Eclipse. I am having trouble setting the build path.

My project works - it is in production. I checked the code out of the code manager and into Eclipse. The code is in the com.x.y package and is located in the java/src/com/x/y directory. (yeah I sanitized the names)

When I set the buildpath to java/src/com, my import statements all break and report, "the import com.x.y cannot be resolved" When I set the buildpath to java/src, however, things look ok, but something is wrong - I can't run my junit tests. I get a ClassNotFoundException: com.x.y.MyClassTest. If I try to run every test in the project, I get a message box that says, "no tests found"

Further, I don't think the code us really being compiled when I rebuild the project.

This can't be hard - I am having a mental block. Someone please throw me a bone!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony,
When you say "setting the build path", which tab are you on? You should be looking at the "source" tab and setting it to "java/src". The com is under it and part of the package name.

Do you have JUnit in your classpath? Can you run MyClassTest if you run it directly (clicking it and selection run as junit tests) ? Is MyClassTest in a different project from the one you are running the tests in? [All of these will give clues to the problem.]
 
Tony Smith
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, exactly. I mean:

1) select the project name in the Navigator tab,
2) right-click to get menu
3) select properties
4) select "java build path" from the choices on the left
5) select the source tab
6) and make sure the source path is java/src. Mine says, "MyProject/java/src" but I think that's right.

The junit test classes are embedded in the same folders/packages as the classes being tested - there is nothing separate about them. if I look at the "libraries" tab on the "Build Path" page, I see junit.jar listed.

I can not run the tests individually. I get the following error:


It also recognized that class as a junit test. It's almost as if it can't find the test's class file. That's something to check.

Also, I do not get any warm and fuzzies that any of the code is actually being compiled, either.

HOWEVER

Because this is a legacy app, I have to use a 1.3 JVM. When I use a 1.5 JVM the test cases run and go green. When I switch back to a 1.3 JVM, the tests can no longer be found. I could understand it if they didn't compile. But this?

I am out of ideas, I'd be happy to try anything at this point.

[ February 15, 2006: Message edited by: Tony Smith ]
[ February 15, 2006: Message edited by: Tony Smith ]
 
Tony Smith
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
update -

What seems to be happening is that once the compiler hits an error, it just stops compiling. That's why it can't find any unit tests - they were never compiled.

Does this sound familiar to anyone?
 
Tony Smith
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Resolution - I added dom.jar, xerxes.jar, and sax.jar.

Apparently, Eclipse requires these and they aren't included in the ancient 1.3 SDK. I am guessing the the project compiler would crash out when it needed to parse an XML file, leaving the project in the partially compiled state I was seeing.

I have no other explanation.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for sharing the answer Tony.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do the following:

Window | Show View | Problems

This will tell you what problems there are. For instance, eclipse will refuse to build until the missing files or folders are added to its build path.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic