Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-1.5.0-gcj-4.5/lib/tools.jar 求解

       在做java JNI项目时,遇到了这样的错误,详情如下:

Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-1.5.0-gcj-4.5/lib/tools.jar
Buildfile: /home/dell/android-ndk-r6/samples/stringJnienv/build.xml
    [setup] Android SDK Tools Revision 12
    [setup] Project Target: Android 1.6
    [setup] API level: 4
    [setup]
    [setup] ------------------
    [setup] Resolving library dependencies:
    [setup] No library dependencies.
    [setup]
    [setup] ------------------
    [setup]
    [setup] WARNING: No minSdkVersion value set. Application will install on all Android versions.
    [setup]
    [setup] Importing rules file: tools/ant/main_rules.xml

-debug-obfuscation-check:

-set-debug-mode:

-compile-tested-if-test:

-pre-build:

-dirs:
     [echo] Creating output directories if needed...

-aidl:
     [echo] Compiling aidl files into Java classes...

-renderscript:
     [echo] Compiling RenderScript files into Java classes and RenderScript bytecode...

-resource-src:
     [echo] Generating R.java / Manifest.java from the resources...

-pre-compile:

compile:
    [javac] /home/dell/android-sdk-linux_x86/tools/ant/main_rules.xml:384: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 1 source file to /home/dell/android-ndk-r6/samples/stringJnienv/bin/classes

BUILD FAILED
/home/dell/android-sdk-linux_x86/tools/ant/main_rules.xml:384: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-1.5.0-gcj-4.5/jre"


电脑详情:

系统:ubuntu 11.4

处理器:AMD

开发环境JDK :java-6-sun-1.6.0.26

运行环境JRE:sun-java6-jre



刚开始以为是  java-1.5.0-gcj-4.5有问题,就盲目的删除重装。然而,这些不起作用。

无奈之下,四处GOOGLE。终于找到了解决方法,如下:

           在终端输入命令:dell@ubuntu:/usr/lib/jvm/java-1.5.0-gcj-4.5$ sudo update-alternatives --config java

           显示如下信息:

           有 3 个候选项可用于替换 java (提供 /usr/bin/java)。

  选择       路径                                优先级  状态
------------------------------------------------------------
* 0            /usr/bin/gij-4.5                       1045      自动模式
  1            /usr/bin/gij-4.4                       1044      手动模式
  2            /usr/bin/gij-4.5                       1045      手动模式
  3            /usr/lib/jvm/java-6-sun/jre/bin/java   63        手动模式

要维持当前值[*]请按回车键,或者键入选择的编号:3
update-alternatives: 使用 /usr/lib/jvm/java-6-sun/jre/bin/java 来提供 /usr/bin/java (java),于 手动模式 中。


如上,我选择了3,然后就大功告成了。


究其原因,是java的默认jre选择错误,上面的操作也是用来更改默认jre的。

希望对大家有帮助!

如果认为好的话,请留言!谢谢!


你可能感兴趣的:(java,android,ubuntu,application,library,dependencies)