I have a compiled binary specifically sun Oracle java that I am using instead of Ubuntu`s apt-get version of java ( what ever it may be ).

I am installing an apt-get package ( maven ) and would like apt-get to use the version of java I have manually installed

I can not install any more packages or tools on the system. I have what ever Ubuntu LTS 12.04 comes with.

  • Are you asking how to specify which java for maven to use? Have you set JAVA_HOME?
    – rickhg12hs
    Oct 15, 2013 at 13:07
  • Apt-get doesn't use Java. Did you mean you want Maven to use a different installation of Java? Do you want to use it only for Maven or for everything? Oct 15, 2013 at 19:07
  • I am using apt-get to intsall maven. I would like apt-get to not install java as part of maven`s dependencies or alternatively add my binary to apt-get Oct 16, 2013 at 8:08
  • 1
    You have said what you want to do, but you haven't said why. If any sun java package will do, you can build (if not already available) a sun java binary (deb) package for Ubuntu. If maven depends on a different version of java, you could also build a custom maven deb which depends on sun java. This of course assumes maven will work with sun java. I have no idea if that is the case. Jun 2, 2014 at 15:01
  • In order to "add your binary to apt-get" you're going to have to build it as a deb package that Provides the java keywords that the maven package Requires. This is possible but most people who know enough about software packaging to know how to do it also know better than to do it unless they really need to. Take that as advice and elaborate on why it's so important to you to use the 'specifically sun Oracle java compiled binary' instead. Dec 12, 2023 at 8:25

2 Answers 2


Sorry, but is not possible. Maven has dependencies of Java and these can't be ignored:

apt-cache depends maven
 |Depends: default-jre
 |Depends: default-jre-headless

So, whenever you try to install maven, java will get installed. The only way to get around this is packaging your own version of Java and install it in your system, otherwise I don't see any other safe way you can do this.


You can run apt-get install maven with the --nodeps flag, but make sure you have all other dependencies of maven installed.

  • Note that apt will attempt to fix these dependencies every single time you try to update or upgrade, because solving dependency issues is literally its job. Dec 12, 2023 at 8:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .