1
votes

I have a java project which imports and uses classes in other projects. I am able to successfully build this project in eclipse. From eclipse I then exported an Ant Buildfile, build.xml. If I attempt to run this file with eclipse or via cmd prompt it fails.

One of the many import reported error is:
[javac] H:...\sortedprovidablemanagertest\SimpleObject.java:8: error: package com.rock.common.core.providable.abstractions does not exist
[javac] import com.rock.common.core.providable.abstractions.AProvidable;

How do I tell Ant to import required classes. I'm guessing these are dependencies. But clearly I'm having trouble setting it up correctly.

1
Is com.rock.common.core.providable.abstractions.AProvidable in a Jar file, has it been compiled to .class form, or is it in source code form?Chad Nouis
@Chad Nouis It has already been compiled to .class but exists in a different project.user1464251

1 Answers

1
votes

In the build.xml, there will be a <javac> task. <javac> takes either a classpath attribute or a nested <classpath> element. Here's an example with a nested <classpath> element:

<javac ...>
    <classpath>
        <pathelement location="PATH_TO_THE_CLASS_FILES_ROOT_DIRECTORY"/>
    </classpath>
    ...
</javac>

The classpath tells the Java compiler where to find the binary dependencies it needs.