aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes setting the build path in Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "setting the build path in Eclipse" Watch "setting the build path in Eclipse" New topic
Author

setting the build path in Eclipse

Tony Smith
Ranch Hand

Joined: Mar 15, 2005
Posts: 77
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

Joined: May 26, 2003
Posts: 31062
    
232

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.]


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Tony Smith
Ranch Hand

Joined: Mar 15, 2005
Posts: 77
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

Joined: Mar 15, 2005
Posts: 77
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

Joined: Mar 15, 2005
Posts: 77
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

Joined: May 26, 2003
Posts: 31062
    
232

Thanks for sharing the answer Tony.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
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.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting the build path in Eclipse