How to generate an entity class from an OPT template?

How to use the generator to generate an entity class from an OPT template?

 java  -jar generator-version.jar
 -h               show help
 -opt <arg>       path to opt file
 -out <arg>       path to output directory
 -package <arg>   package name
 -config <arg>    optional Path to config file

GitHub: Usage

When trying to do this in the syntax above, I got an error message:

Error: Failed to initialize the Main Class org.ehrbase.openehr.sdk.generator.ClassGeneratorRunner
Reason: java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException

Thanks.

@linforest are you using the jar downloaded from maven central?
Can you try building the jar from the source code? Just clone the openEHR SDK, do a mvn clean install of the project and then try with the openEHR_SDK\generator\target\generator-2.17.0.jar.

Not sure why it’s not working with the jar from maven central, or if it’s supposed to work directly from there.

1 Like

If you look at openEHR_SDK/generator/pom.xml at develop · ehrbase/openEHR_SDK · GitHub

During build it copies the dependencies to /lib and takes them from there.
So you seam to be missing the java dependencies

1 Like

Yes, it’s from maven central. As your suggested, I will try a locally-built copy. Thanks.

1 Like

Your guess is likely right because the ehrbsse jars are limited to client, generator and their dependencies. Thanks.

1 Like