How to tell if a certain package exists in the apt repos? [duplicate]

I am specifically interested in determining whether a 32-bit version of OpenJDK 8 exists in the apt/Ubuntu repos.

According to this answer, you can install the 32-bit version of the Open JDK 7 packages via:

sudo apt-get install openjdk-7-jre:i386

How can I do the equivalent of an ls -al to see what packages exist for OpenJDK 8, and specifically, the 32-bit ones?


Solution 1:

First of all the availability of packages (and different versions) depend highly on the release you have.

One can do

apt-cache search --names-only '^openjdk-8-.*'

to look for package names that starts with openjdk-8. You should run sudo apt-get update first.

For example in my 14.04 :

$ apt-cache search --names-only '^openjdk-8-.*'
openjdk-8-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-8-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-8-doc - OpenJDK Development Kit (JDK) documentation
openjdk-8-jdk - OpenJDK Development Kit (JDK)
openjdk-8-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-8-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-8-jre-jamvm - Alternative JVM for OpenJDK, using JamVM
openjdk-8-jre-zero - Alternative JVM for OpenJDK, using Zero/Shark
openjdk-8-source - OpenJDK Development Kit (JDK) source files

Now for 32 bit packages, you need to enable multiarch support first and then you can use apt-cache policy on individual packages to check their availability :

$ apt-cache policy openjdk-8-jre:i386
openjdk-8-jre:i386:
  Installed: (none)
  Candidate: 8u45-b14-1
  Version table:
     8u45-b14-1 0
        500 http://archive.ubuntu.com/ubuntu/ vivid/universe i386 Packages

Solution 2:

apt-cache search OpenJDK  

and, of course:

man apt-cache

and, in the repository for MY version of Ubuntu (14.04.3 LTS), the answer is No. YMMV