How to build android project with openjdk on Ubuntu?
Solution 1
Make sure you have the openjdk JDK
installed. By default you probably only have the JRE
installed. If you open Synaptic
, search for openjdk
and then you'll see both the JDK
and the JRE
. Select the JDK package and install. I think the actual packagename is openjdk-6-jdk
.
or use the commandline
# sudo apt-get install openjdk-6-jdk
Solution 2
Android's official webpage reccomends the use of the official JDK from Sun/Oracle that you can download at http://www.oracle.com/technetwork/java/javase/downloads/index.html , the use of OpenJDK is unsupported and highly unrecommended.
You don't need to install the official JDK in your system, if this is what you are worring about, just download the *.bin version of the JDK of your choice ( i suggest the 1.6 version ), unpack everything by executing the *.bin in a terminal, and just modify 2 environment variable like this:
-
PATH
, add the path to the jdk executablespath_to_jdk/bin/
to yourPATH
-
JAVA_HOME
, setJAVA_HOME
to the generic path of your jdk, NOT thebin
orlib
path, just as before without bin, only path_to_jdk/
you can modify this variables by editing the /etc/bash.bashrc
or your local .bashrc
, I suggest to edit the one under /etc
you also want to remove your actual OpenJDK from your system.
jcubic
My name is Jakub T. Jankiewicz, I'm coding mostly in JavaScript. I love Lisp Macros, jQuery library, ReactJS, CSS3, HTML5, SVG, GNU/Linux, GNU Emacs and Inkscape. Working with JavaScript and R for Roche/Genentech via Astek Poland. my english blog - In Code We Trust my polish blog - Głównie JavaScript (ang. Mostly JavaScript) Usefull Links Other links Yet another links Few of my JavaScript Open Source projects: jQuery Terminal: JavaScript library for Web based Terminal Emulator LIPS - Powerful Scheme based lisp interpreter written in JavaScript sysend.js: Library for sending messages between Windows and Tabs Gaiman Programming Language and Text based Game engine GIT Web Terminal Posts: EchoJS News, EchoJS News (2), HackerNews
Updated on June 22, 2022Comments
-
jcubic almost 2 years
I found this Is Sun Java really necessary for using Android SDK on Ubuntu 10.10? I prefer OpenJDK but I can't build android project on Ubuntu. When I try:
$ ant debug
I got:
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar ... BUILD FAILED /home/kuba/projects/Android/android-sdk-linux/tools/ant/build.xml:651: The following error occurred while executing this line: /home/kuba/projects/Android/android-sdk-linux/tools/ant/build.xml:672: 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"
I have java version:
$ java -version java version "1.6.0_20" OpenJDK Runtime Environment (IcedTea6 1.9.13) (6b20-1.9.13-0ubuntu1~10.10.1) OpenJDK Client VM (build 19.0-b09, mixed mode, sharing)