Ant 找不到 javac,在 Ubuntu 上不会设置 JAVA_HOME [英] Ant unable to find javac, JAVA_HOME won't set on Ubuntu

查看:35
本文介绍了Ant 找不到 javac,在 Ubuntu 上不会设置 JAVA_HOME的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Ubuntu 10.04 i386 服务器(无头)上有一个名为 Hello 的 Android 项目.它包含了一个 Android 项目文件夹应该有的所有东西.我首先在项目文件夹中使用这个 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

然后我尝试像这样用 ant 构建 .apk:

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

ant debug

我收到此错误:

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"

这让我很困惑,因为就在我运行 ant debug 之前,我运行:

which is very confusing to me because just before I run ant debug I run:

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?

Did you install the JDK?

当您安装 Ubuntu 时,仅将 JRE 作为默认软件包的一部分安装.不幸的是,Ubuntu 的包管理将目录命名为好像 JRE 与 JDK 一起安装一样.即使 JDK 不存在,该目录也被命名为 java-6-openjdk.

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.

这篇关于Ant 找不到 javac,在 Ubuntu 上不会设置 JAVA_HOME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆