Java import issue - import com.daml cannot be resolved

Hi team,

When I generate Java Code by downloading codegen-java-1.11.2.jar and running: java -jar java-codegen.jar -o target/generated-sources/daml daml/my-project/main.dar (following this tutorial Generate Java code from Daml — Daml SDK 1.14.0 documentation)

I got issue with the import.

Could you please advise?

Cheers,
JP

1 Like

Looks like that documentation is from before the introduction of daml codegen java ..., which I would recommend you use for this so that you can use the codegen from the same SDK version (which shouldn’t be a strict requirement, but anyway recommended to keep up with the latest updates). Apologies for that, we’ll fix the docs as soon as possible.

More specifically regarding your question: the codegen simply generates that source code to use the bindings, whose imports are missing here. Since there are a few de-facto standards when it comes to dependency management, the codegen leaves it to the developer. You still have to set up your project so that the relevant dependencies are pulled in, using Maven, Gradle or whatever else you happen to be using. The docs explain how to set up the Maven dependencies (here for version 1.14.0).

This is also probably something that we can document better.

3 Likes

Cheers, this solved the issue !

1 Like