Cannot perform mvn clean install

Hi all,

I’m pretty new with all open source. I had recently started exploring what OpenMRS does and all. Right now, I’m setting up the environment.

I had cloned the git repo of openmrs-core from : https://github.com/openmrs/openmrs-core I followed the instructions given in the manual and have set up the eclipse ide and required tools.

But when I try to perform mvn clean install, I’m constantly facing this issue

  1. Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.1:compile
  2. \api\src\main\java\org\openmrs\ObsPostLoadEventListener.java:[14,23] error: package javax.annotation does not exist

I tried the quick fix suggested for 1 from the manual - installing “Maven Integration for Eclipse” from eclipse marketplace. I don’t understand the second because if I try to add a new dependency which it says missing then it gives many more errors.

Thanks in advance! https://pastebin.com/vcj4JNAp

Downgrade to Java 8 and compile again.

2 Likes

u can use https://openjdk.java.net/install/ for the download and the installation guidelines

1 Like

Thank you @dkayiwa @jnsereko I have downgraded to java 8 and it builds successfully :+1: without any errors.

Dear Daniel,

I am getting exactly same error as asked in the question. Pretty new to OpenMRS and trying to setup the environment. Earlier I had JDK14 then I downgraded to 8 I suppose, following version info

java version “1.8.0_241” Java™ SE Runtime Environment (build 1.8.0_241-b07) Java HotSpot™ 64-Bit Server VM (build 25.241-b07, mixed mode)

Still am getting the error. Is above java version ok?

Also, I followed this - https://wiki.openmrs.org/display/docs/User+Interface+Modules ( For Developers section)

Best Regards, Supriya

It should be. What’s the output of mvn -v?

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: D:\MedicalProj\apache-maven-3.6.3\bin… Java version: 1.8.0_241, vendor: Oracle Corporation, runtime: D:\MedicalProj\Java1.8 Default locale: en_US, platform encoding: Cp1252 OS name: “windows 10”, version: “10.0”, arch: “amd64”, family: “windows”

Can you use pastebin.com to paste the output that happens when you run mvn clean install?

Sorry , I restarted my tablet to see if something works, and now it gives me below diff error, I will try pastebin now -

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.1:compile (default-cli) on project openmrs-api: Compilation failure

[ERROR] Unable to locate the Javac Compiler in:

[ERROR] D:\MedicalProj\Java1.8…\lib\tools.jar

[ERROR] Please ensure you are using JDK 1.4 or above and

[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).

[ERROR] In most cases you can change the location of your Java

[ERROR] installation by setting the JAVA_HOME environment variable.


I will check tools.jar fix too.

Thank you for your time n help!

https://pastebin.com/ZNsfifRa

@supriyat It’s exactly like the error says: you need to have the Java 8 JDK installed, not just the JRE.

Dear Ian, Got the right JDK downloaded again n reinstalled it. Build successful! yet to explore OpenMRS further. Thanks a lot again! Best Regards, Supriya

[INFO] Reactor Summary for OpenMRS 2.4.0-SNAPSHOT:

[INFO]

[INFO] OpenMRS … SUCCESS [ 0.370 s]

[INFO] openmrs-tools … SUCCESS [ 0.032 s]

[INFO] openmrs-test … SUCCESS [ 0.264 s]

[INFO] openmrs-api … SUCCESS [ 18.756 s]

[INFO] openmrs-web … SUCCESS [02:12 min]

[INFO] openmrs-webapp … SUCCESS [ 40.792 s]

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 03:13 min

[INFO] Finished at: 2020-04-19T01:58:10+05:clock1030:

[INFO] ------------------------------------------------------------------------

@supriyat Glad you got there!

2 Likes

I’m using Eclipse 2022-03 which includes/requires Java 14. Do I have to maven compile from command line, and make sure maven uses a JDK 8? It’s very inconvenient.

With platform 2.4 you can use java 14 as per the release notes on this link OpenMRS Platform 2.4.0 Released

Thanks, currently I’m just trying to compile openmrs-core