Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

No system compiler found, Did you install the JRE instead of the JDK? #1332

Closed
zoom2manoj opened this issue May 8, 2017 · 2 comments
Closed

Comments

@zoom2manoj
Copy link

zoom2manoj commented May 8, 2017

I'm trying to build sample demo using as below command on Window system,

From the rootcross-platform-scale-2015-demo/ directory demo_app_android is an alias in .buckconfig for //android:demo-app. Either works. buck build demo_app_android

but I'm getting issue as below :

`Not using buckd because watchman isn't installed.
[-] PARSING BUCK FILES...FINISHED 0.0s [100%]
BUILD FAILED: //android:demo-app#compile_uber_r_dot_java failed on step javac wi
th an exception:
No system compiler found. Did you install the JRE instead of the JDK?
com.facebook.buck.util.HumanReadableException: No system compiler found. Did you
install the JRE instead of the JDK?
at com.facebook.buck.jvm.java.JdkProvidedInMemoryJavac.createCompiler(Jd
kProvidedInMemoryJavac.java:63)
at com.facebook.buck.jvm.java.Jsr199Javac.buildWithClasspath(Jsr199Javac
.java:124)
at com.facebook.buck.jvm.java.JavacStep.performBuild(JavacStep.java:200)

    at com.facebook.buck.jvm.java.JavacStep.tryBuildWithFirstOrderDeps(Javac

Step.java:190)
at com.facebook.buck.jvm.java.JavacStep.execute(JavacStep.java:151)
at com.facebook.buck.step.DefaultStepRunner.runStepForBuildTarget(Defaul
tStepRunner.java:47)
at com.facebook.buck.rules.CachingBuildEngine.executeCommandsNowThatDeps
AreBuilt(CachingBuildEngine.java:1387)
at com.facebook.buck.rules.CachingBuildEngine.lambda$11(CachingBuildEngi
ne.java:339)
at com.facebook.buck.util.concurrent.WeightedListeningExecutorService.la
mbda$0(WeightedListeningExecutorService.java:77)
at com.google.common.util.concurrent.Futures$AsyncChainingFuture.doTrans
form(Futures.java:1442)
at com.google.common.util.concurrent.Futures$AsyncChainingFuture.doTrans
form(Futures.java:1433)
at com.google.common.util.concurrent.Futures$AbstractChainingFuture.run(
Futures.java:1408)
at com.google.common.util.concurrent.Futures$2$1.run(Futures.java:1177)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

[-] BUILDING...FINISHED 0.5s [100%]`

Can anyone suggest me what I'm doing wrong in these steps according to https://buckbuild.com/setup/getting_started.html

@xzstar
Copy link

xzstar commented Aug 17, 2017

The reason is System.getProperty("java.home") points to a jre directory.
Workaround: copy your jdk/lib/tools.jar to jre/lib/tools

@seanpoulter
Copy link

We should add solution(s) for this to the Getting Started and/or Troubleshooting docs and incude the link in the error message. This is as much of a problem of setting up your PATH as copying files, and since it's part of the build environment setup it'll probably cause problems for a few folks.

FWIW, here's my process to diagnose the problem and fix it by updating the PATH before I build.

  1. getSystemJavaCompiler() must be null to get the error message:

    // file: Reproduce.java
    import javax.tools.ToolProvider;
    import javax.tools.JavaCompiler;
    
    public class Reproduce {
    	public static void main(String[] args) {
    		String home = System.getProperty("java.home");
    		System.out.printf("java.home:\t%s\n", home);
    
    		JavaCompiler c = ToolProvider.getSystemJavaCompiler();
    		System.out.printf("JavaCompiler:\t%s\n", c);
    	}
    }
    > javac Reproduce.java
    > java Reproduce
    java.home:	C:\Program Files (x86)\Java\jre1.8.0_151
    JavaCompiler:	null
  2. Should this be using JAVA_HOME?

    > set java_
    JAVA_HOME=c:\Program Files (x86)\Java\jdk1.8.0_151
    JAVA_JDK_BIN=C:\Program Files (x86)\Java\jdk1.8.0_151\bin
    

    Doesn't look like it.
    The docs say "java.home" is the JRE installation directory.

  3. Which java is being used?

    > where java
    C:\ProgramData\Oracle\Java\javapath\java.exe
    C:\Program Files (x86)\Java\jdk1.8.0_151\bin\java.exe
  4. There's an unresolved bug to improve the getSystemJavaCompiler() docs to say it must be called with the JDK not the JRE.

  5. Does it work if we use java from the JDK instead of the JRE?

    > set PATH=%JAVA_JDK_BIN%;%PATH%
    > where java
    C:\Program Files (x86)\Java\jdk1.8.0_151\bin\java.exe
    C:\ProgramData\Oracle\Java\javapath\java.exe
    
    > java Reproduce
    java.home:	C:\Program Files (x86)\Java\jdk1.8.0_151\jre
    JavaCompiler:	com.sun.tools.javac.api.JavacTool@17327b6

    Bingo.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants