0

Just a forewarning, I'm incredibly new to UNIX in general, so if you could keep all answers relatively simple that would be great

I am trying to install java on my machine, and when I try to install the .rpm file, I get an error that tells me I am missing dependencies.

Any suggestions?

These are the errors:

root@cole-ThinkPad-T440s:/home/cole/java# rpm -ivh jdk-8u111-linux-x64.rpm
rpm: RPM should not be used directly install RPM packages, use Alien instead!
rpm: However assuming you know what you are doing...
error: Failed dependencies:
/bin/basename is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/bin/cat is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/bin/cp is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/bin/gawk is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/bin/grep is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/bin/ln is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/bin/ls is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/bin/mkdir is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/bin/mv is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/bin/pwd is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/bin/rm is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/bin/sed is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/bin/sort is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/bin/touch is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/usr/bin/cut is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/usr/bin/dirname is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/usr/bin/expr is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/usr/bin/find is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/usr/bin/tail is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/usr/bin/tr is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/usr/bin/wc is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64
/usr/sbin/update-alternatives is needed by jdk1.8.0_111-2000:1.8.0_111-  fcs.x86_64
/bin/sh is needed by jdk1.8.0_111-2000:1.8.0_111-fcs.x86_64

root@cole-ThinkPad-T440s:/home/cole/java#

Once I install java, I also want to set the jdk so that eclipse can locate it. I could also use a bit of help on how to do that

1

OpenJDK is a development environment for building applications, applets, and components using the Java programming language. To install OpenJDK 9 in Ubuntu 16.04 from the terminal type:

sudo apt install openjdk-9-jdk

To install OpenJDK 8 replace the 9 in the above command with 8.

To display the path to the default JDK type:

update-alternatives --display java

To install Oracle's proprietary Java JDK from a .deb file that is downloaded from the Oracle website see How can I install Sun/Oracle's proprietary Java JDK 6/7/8 or JRE?

Because you may have installed multiple versions of Java from .rpm files, .deb files and/or directly from the Ubuntu repositories, it is possible that you may have messed up the Java path. This question is about how to change the Java path after installing Java from multiple sources - Ubuntu: change the path from OpenJDK 6 to Oracle JDK 7

You can use either update-alternatives (which is installed by default in Ubuntu) or update-java-alternatives (which is installed when openjdk-9-jdk is installed) to manually choose which Java to use before running an application. See update-java-alternatives vs update-alternatives --config java.

  • Hi karel. I tried this approach, and eclipse did not automatically detect it. Any other suggestions? – drakzuli Jan 8 '17 at 0:30
0

First get one of the zip files from the Oracle Java website. Do not download the .rpm file because it is for Red Hat Linux. It might be a GZip which has an extension like .gz or .gzip or .tgz or .tar.gz. Pick the JDK file rather than the JRE file. There will be a JRE inside the JDK download anyway. The JDK is for developers. The JRE is not for developing.

If you don't want Oracle's you can get the OpenJDK.

When installing I link to the JDK rather than the JRE/bin simply because I don't want to presume that all JDK's will contain the JRE, even though this one does.

On a single user machine you can unzip it anywhere. If you are on a multi-user machine there are standard places to unzip it. You can read about them at Wikipedia and of course also at the references it provides. Cut and paste or move the zip file to where you intend to unzip. You can right-click the archive to unzip it.

On a single user machine I can unzip it anywhere so for convenience I put it somewhere under my own home directory. For the following I assume it was unzipped (extracted) under /home/YOURNAME/programs. It's better to spell it out as /home/YOURNAME/.... rather than use ~/..... The following commands can be adjusted depending upon where you actually unzipped. When adjusting just ls /home/YOURNAME/programs/....... to make sure the file really is there and that you are spelling the path properly. There will be a java file, a javaws file, a jar file, and a javac file which in the case of Oracle JDK are all in the same directory. By the way if you browse around you will notice some of the files are duplicates in the Oracle download because they have a java file in the jre directory and the same java file in the jdk directory. (It could be jre/bin or jdk/bin or something like that.) If you are a developer stick with the jdk path.

When you are sure of the path then adjust the following commands.

sudo update-alternatives --install "/usr/bin/java" "java" "/home/YOURNAME/programs/jdk1.8.0/bin/java" 1

sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/home/YOURNAME/programs/jdk1.8.0/bin/javaws" 1 

sudo update-alternatives --install "/usr/bin/jar" "jar" "/home/YOURNAME/programs/jdk1.8.0/bin/jar" 1

sudo update-alternatives --install "/usr/bin/javac" "javac" "/home/YOURNAME/programs/jdk1.8.0/bin/javac" 1 

sudo update-alternatives --config java

sudo update-alternatives --config javaws

sudo update-alternatives --config jar

sudo update-alternatives --config javac

The update-alternatives --config commands might ask you to answer a question so just answer it.

Note that this installation still leaves the JAVA_HOME environment variable undefined. I did not need it to be defined until I installed a package that cared about it. If you install something that needs it to be defined then you can do this in your ~/.bashrc file:

export JAVA_HOME=jdk-install-dir
export PATH=$JAVA_HOME/bin:$PATH

NOTE THAT THE /bin PART GOES IN THE PATH BUT NOT IN JAVA_HOME ITSELF.
THAT MEANS JAVA_HOME IS THE THE DIRECTORY ABOVE THE BIN DIRECTORY.

Lastly, whether it is Thanksgiving Day or not, be thankful that you are not editing paths in a tiny Windows ® dialog that cannot be maximized or stretched so that you cannot see the whole path and you have to do it in a variable pitch font that makes I and 1 and l look the same.

  • I tried to enter these commands, and I got an error saying that "1" is not a directory – drakzuli Jan 8 '17 at 0:48
  • You probably mis-typed something. Be sure to use quotes if your path has spaces. Put a space before the 1 which is at the end of the command. – H2ONaCl Jan 8 '17 at 0:52
  • Ok so the first 4 commands worked, but the config command gives me this message: There is only one alternative in link group java (providing /usr/bin/java): /home/cole/java/jdk1.8.0_111/bin/java Nothing to configure. – drakzuli Jan 8 '17 at 0:59
  • If the update-alternatives --config asks a question just read the question and answer it. If it says "nothing to configure" then there is no question. It's fine. – H2ONaCl Jan 8 '17 at 1:00
  • It worked! You rock! – drakzuli Jan 8 '17 at 1:02

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.