"Unable to locate the Javac Compiler" when building with Eclipse

Tags: #<Tag:0x00007f0f19a9cd18> #<Tag:0x00007f0f19a9cb60>
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] OpenMRS
[INFO] openmrs-tools
[INFO] openmrs-test
[INFO] openmrs-api
[INFO] openmrs-web
[INFO] openmrs-webapp
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building OpenMRS 1.12.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ openmrs ---
[INFO] 
[INFO] --- buildnumber-maven-plugin:1.1:create (default) @ openmrs ---
[INFO] Checking for local modifications: skipped.
[INFO] Updating project files from SCM: skipped.
[INFO] ShortRevision tag detected. The value is '6'.
[INFO] Executing: cmd.exe /X /C "git rev-parse --verify --short=6 HEAD"
[INFO] Working directory: D:\openmrs-core\openmrs-core-master
[INFO] Storing buildNumber: 0 at timestamp: 1436978170908
[INFO] ShortRevision tag detected. The value is '6'.
[INFO] Executing: cmd.exe /X /C "git rev-parse --verify --short=6 HEAD"
[INFO] Working directory: D:\openmrs-core\openmrs-core-master
[INFO] Storing buildScmBranch: UNKNOWN_BRANCH
[INFO] 
[INFO] --- build-helper-maven-plugin:1.5:parse-version (parse-version) @ openmrs ---
[INFO] 
[INFO] --- maven-jar-plugin:2.3.2:test-jar (default) @ openmrs ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: D:\openmrs-core\openmrs-core-master\target\openmrs-1.12.0-SNAPSHOT-tests.jar
[INFO] 
[INFO] --- license-maven-plugin:2.6:check (default) @ openmrs ---
[INFO] Checking licenses...
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ openmrs ---
[INFO] Installing D:\openmrs-core\openmrs-core-master\pom.xml to C:\Users\Piyush\.m2\repository\org\openmrs\openmrs\1.12.0-SNAPSHOT\openmrs-1.12.0-SNAPSHOT.pom
[INFO] Installing D:\openmrs-core\openmrs-core-master\target\openmrs-1.12.0-SNAPSHOT-tests.jar to C:\Users\Piyush\.m2\repository\org\openmrs\openmrs\1.12.0-SNAPSHOT\openmrs-1.12.0-SNAPSHOT-tests.jar
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building openmrs-tools 1.12.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ openmrs-tools ---
[INFO] Deleting D:\openmrs-core\openmrs-core-master\tools\target
[INFO] 
[INFO] --- buildnumber-maven-plugin:1.1:create (default) @ openmrs-tools ---
[INFO] 
[INFO] --- build-helper-maven-plugin:1.5:parse-version (parse-version) @ openmrs-tools ---
[INFO] 
[INFO] --- maven-resources-plugin:2.4:resources (default-resources) @ openmrs-tools ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 7 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.1:compile (default-compile) @ openmrs-tools ---
[INFO] Compiling 1 source file to D:\openmrs-core\openmrs-core-master\tools\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
  C:\Program Files\Java\jre7\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] OpenMRS ............................................ SUCCESS [  2.541 s]
[INFO] openmrs-tools ...................................... FAILURE [  0.422 s]
[INFO] openmrs-test ....................................... SKIPPED
[INFO] openmrs-api ........................................ SKIPPED
[INFO] openmrs-web ........................................ SKIPPED
[INFO] openmrs-webapp ..................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.312 s
[INFO] Finished at: 2015-07-15T22:06:12+05:30
[INFO] Final Memory: 19M/355M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.1:compile (default-compile) on project openmrs-tools: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre7\..\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.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :openmrs-tools

any one familiar to these errors please respond…!

Looks like your java is not set up well. You need to set up JAVA_HOME and add the java compiler to your PATH after installing java jdk.

I see you instead have jre under C:\Program Files\Java which most jdk packages install anyway. See:

after configuring the build path and building the project again i am getting this error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.1:compile (default-compile) on project openmrs-tools: Compilation failure
[ERROR] Failure executing javac, but could not parse the error:
[ERROR] javac: invalid target release: 1.8
[ERROR] Usage: javac <options> <source files>
[ERROR] use -help for a list of possible options
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :openmrs-tools

If you’re trying to build master, then you need Java 8.

This message implies you’re using a Java version < 8.

1 Like

problem solved. and now i am using it. thanks pascal and k_joseph

1 Like