蚂蚁无法找到的javac,JAVA_HOME不会在Ubuntu上设置会在、蚂蚁、JAVA_HOME、javac

2023-09-05 05:43:37 作者:雨潇潇

我有一个Android项目名为Hello在我的Ubuntu 10.04的i386服务器(无头)。它包含了所有事物的Andr​​oid项目文件夹应该有。我第一次同时在项目文件夹中使用该synax建立在bash项目:

I have an Android Project called Hello on my Ubuntu 10.04 i386 Server (headless). It contains all things an Android project folder should have. I first build the project in bash while in the Project folder using this synax:

./android create project --target 5 --name HelloCompile --path ../../Projects/Hello --activity HelloActivity --package com.code.Hello

然后我尝试用蚂蚁,像这样建.apk文件:

then I try to build the .apk with ant like so:

ant debug

我得到这个错误:

I get this error:

BUILD FAILED
/home/myusername/www/sdk/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-6-openjdk/jre"

这是非常令人困惑我,因为之前我跑蚂蚁调试我运行:

export JAVA_HOME=/usr/lib/jvm/java-6-openjdk

我知道的作品,因为 printenv 在bash shell中的回报:

which I know works because printenv in bash shell returns:

JAVA_HOME=/usr/lib/jvm/java-6-openjdk

要复合这一点,加入这一行到我的/ etc / environment文件

to compound this, adding this line to my /etc/environment file

export JAVA_HOME=/usr/lib/jvm/java-6-openjdk

不解决此问题有两个 - 我得到了同样的错误。无论我做改变的事实Ubunut仍然认为 / usr / lib中/ JVM / Java的6-的OpenJDK / JRE 是JAVA_HOME。这是怎么了?我已经在这了太多时间。

does not fix the problem either - I get the same error. Nothing I do changes the fact Ubunut still thinks /usr/lib/jvm/java-6-openjdk/jre is the JAVA_HOME. What is going wrong? I've been at this for too many hours.

推荐答案

是否安装了JDK?

当您安装Ubuntu只JRE安装为默认软件包的一部分。不幸的是Ubuntu的软件包管理名字仿佛是JRE与JDK一起安装的目录。该目录被命名为的java-6-的OpenJDK 即使JDK是不是会present。

When you install Ubuntu only the JRE is installed as part of the default packages. Unfortunately Ubuntu's package management names the directory as if the JRE were installed along with the JDK. The directory is named java-6-openjdk even though the JDK is not be present.

执行以下操作:

sudo apt-get install openjdk-6-jdk

这将在同一目录中安装JDK。

It will install the JDK in that same directory.