简体   繁体   中英

unable to locate the java compiler com.sun.to while running grails app in ubuntu

i tried different fixes avaiable with this name. but non worked.

i have following under printenvi.

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/root/bin:/home/thinkvidya-kiran/programs/jdk1.6.0_45/bin:/home/thinkvidya-kiran/programs/jdk1.6.0_45/bin:/home/thinkvidya-kiran/programs/james-2.3.2/bin:/home/thinkvidya-kiran/programs/grails-2.1.1/bin
PWD=/usr/lib/jvm
JAVA_HOME=/home/thinkvidya-kiran/programs/jdk1.6.0_45

tried

sudo ln -s /path/to/jre*/bin/java /usr/bin/java

and java and javac are giving me correct output. and i tried putting -vm thing in eclispe.ini. non working for me its giving following error.

 | Loading Grails 2.1.1
| Configuring classpath.
| Environment set to development.....
| Compiling 1 source files..
| Compiling 2 source files.
| Error Compilation error: startup failed:
General error during semantic analysis: unable to locate the java compiler com.sun.tools.javac.Main, please change your classloader settings
java.lang.ClassNotFoundException: unable to locate the java compiler com.sun.tools.javac.Main, please change your classloader settings
    at org.codehaus.groovy.tools.javac.JavacJavaCompiler.findJavac(JavacJavaCompiler.java:190)
    at org.codehaus.groovy.tools.javac.JavacJavaCompiler.compile(JavacJavaCompiler.java:49)
    at org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit.gotoPhase(JavaAwareCompilationUnit.java:97)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:513)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:482)
    at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:60)
    at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:216)
    at org.codehaus.groovy.ant.Groovyc.compile(Groovyc.java:935)
    at org.codehaus.groovy.grails.compiler.Grailsc.compile(Grailsc.java:79)
    at org.codehaus.groovy.ant.Groovyc.execute(Groovyc.java:629)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:622)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at groovy.util.AntBuilder.performTask(AntBuilder.java:260)
    at groovy.util.AntBuilder.nodeCompleted(AntBuilder.java:220)
    at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:147)
    at groovy.util.AntBuilder.doInvokeMethod(AntBuilder.java:170)
    at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:64)
    at org.codehaus.gant.GantBuilder.invokeMethod(GantBuilder.java:99)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at org.codehaus.groovy.grails.compiler.GrailsProjectCompiler.compile(GrailsProjectCompiler.groovy:263)
    at org.codehaus.groovy.grails.compiler.GrailsProjectCompiler$compile$0.callCurrent(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
    at org.codehaus.groovy.grails.compiler.GrailsProjectCompiler.compile(GrailsProjectCompiler.groovy:234)
    at org.codehaus.groovy.grails.compiler.GrailsProjectCompiler$compile.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
    at _GrailsCompile_groovy$_run_closure2_closure6_closure7.doCall(_GrailsCompile_groovy:48)

I had the same problem in Debian with the latest version of Grails 2.4.3. I added the jdk tools.jar in classpath to get past the error.

In Debian I had to do

export CLASSPATH=/usr/lib/jvm/java-7-openjdk-amd64/lib/tools.jar

In Windows, you will have to locate the tools.jar and add it to the CLASSPATH environment variable.

I did bumped into the same issue when I was installing whole pack on newly launched EC2 instance with preinstalled java. Checking java version gave me this:

ubuntu@ip-*-*-*-*:/usr/local/java$ java -version
java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.2) (7u65-2.5.2-3~14.04)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

But checking the compiler was not that perfect:

ubuntu@ip-*-*-*-*:/usr/local/java$ javac -version
The program 'javac' can be found in the following packages:
 * default-jdk
 * ecj
 * gcj-4.8-jdk
 * openjdk-7-jdk
 * gcj-4.6-jdk
 * openjdk-6-jdk
Try: sudo apt-get install <selected package>

So i did:

 sudo apt-get install openjdk-7-jdk

And that did the trick:

ubuntu@ip-172-30-0-152:/usr/local/java$ javac -version
javac 1.7.0_65

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM