How to create an Android project with openjdk on Ubuntu?

I found this. Is Sun Java really necessary to use the Android SDK on Ubuntu 10.10? I prefer OpenJDK , but I cannot build an 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 a 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) 
+6
source share
3 answers

Make sure openjdk JDK installed. By default, probably only JRE installed. If you open Synaptic , find openjdk and then you will see both the JDK and the JRE . Select the JDK package and install it. I think the actual name of the package is openjdk-6-jdk .

or use the command line

 # sudo apt-get install openjdk-6-jdk 
+6
source

The official Android web page recommends using the official Sun / Oracle JDK, which you can download at http://www.oracle.com/technetwork/java/javase/downloads/index.html , using OpenJDK is unsupported and extremely unmanageable.

You do not need to install the official JDK on your system, if this is what you are worried about, just download the * .bin version of the JDK of your choice (I offer version 1.6), unzip everything by executing * .bin in the terminal and just changing 2 variables environment as follows:

  • PATH , add the path to the jdk path_to_jdk/bin/ to your PATH
  • JAVA_HOME , install JAVA_HOME in the shared path of your jdk, and not in the bin or lib path, as before without bin, only path_to_jdk /

you can change these variables by editing /etc/bash.bashrc or your local .bashrc , I suggest editing the file under /etc

You also want to remove your real OpenJDK from your system.

+4
source

I installed the same error (on Debian / Ubuntu) by installing gcj-jdk . Before installing this package, I had java-7-openjdk , but not tools.jar inside its directory. After installing gcj-jdk I found tools.jar and made a symbolic link to it inside the directory where ant wants it to be.

0
source

Source: https://habr.com/ru/post/918875/


All Articles