View Full Version : New Ubuntu User - Trying to install Java 6u14 SDK

July 11th, 2009, 04:03 PM
Hello, All. This is very new to me. I've been developing on a Windows machine for quite some time and wanted a change. I'm spending the weekend getting my machine set up for work again, but I'm having difficulty getting things installed properly.

I downloaded the Java 6u14 SDK bin and installed, but then realized that I did everything in the desktop. Now, I'm trying to figure out how to get Java installed in the usr directory (which, I believe, is where it goes). Unfortunately, there is no "java" directory in "usr", and using "mkdir java" from the command line gives me "permission denied".

Any step-by-step help would be greatly appreciated.


July 11th, 2009, 04:11 PM
Use sudo mkdir. Modifying anything outside of your home folder usually requires sudo. I think the recommended location would be usr/local then just copy the entire folder there, so usr/local/jdk1.6.0_14. That's exactly what I did. If you want to install Netbeans manually (not from add/remove or apt-get), it goes into the same /usr/local folder. Actually, the binary Netbeans installer does that for you automatically.

July 11th, 2009, 04:20 PM
Oh yeah, duh. If you are going to copy the folder and not create, use cp -r.

sudo cp -r /home/username/Desktop/jdk1.6.0_14/ /usr/local/jdk1.6.0_14

Where username is your username or login name.

July 11th, 2009, 06:45 PM
Thanks, prvteprts. I was able to get the jdk into the correct directory. Now on to the next question: When typing java -version in the command line, I get "command cannot be found".

Where and how do I set the path for java?

July 11th, 2009, 08:07 PM
I would strongly suggest just installing Java from the repositories. That will take care of setting up paths, etc. and is quite a bit less painful.

July 11th, 2009, 11:11 PM
I'd suggest copying/extracting the JDK into your home dir, say into /home/yournick/apps/jdk6u14.
Now you need the "java" & "javac" executables from your new JDK to run by default, thus:
-create a dir "bin" in your home dir (thus "/home/yournick/bin" if it doesn't exist)
-create and put there 2 (soft) links called "java" & "javac" pointing correspondingly to
"path-to-new-jdk/bin/java" & "path-to-new-jdk/bin/javac".
(To create a soft link right-click the corresponding files from Nautilus, choose "Make link", put those links into the "/home/yournick/bin" dir and rename them to "java" & "javac" accordingly).

Changes will take effect after restart (or maybe after logout & login back).
Sounds little crazy but it works.

July 12th, 2009, 09:18 AM
I would strongly suggest just installing Java from the repositories. That will take care of setting up paths, etc. and is quite a bit less painful.

You could do this, but I'm not sure if it's the most updated version. You must also be careful to install the correct "kind" of java you want, as there are a lot of them in the repositories.

For setting up the path, I found this: http://ubuntuforums.org/archive/index.php/t-8523.html

But froggyswamp's method is interesting. I did something like that before in Windows. You could try that out.

July 12th, 2009, 10:44 AM
Up to date jaunty install with sun java 6.0 jdk install:

slavik@slavik-desktop:~$ uname -a
Linux slavik-desktop 2.6.28-13-generic #44-Ubuntu SMP Tue Jun 2 07:55:09 UTC 2009 x86_64 GNU/Linux
slavik@slavik-desktop:~$ cat /etc/lsb-release
slavik@slavik-desktop:~$ java -version
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) 64-Bit Server VM (build 14.0-b16, mixed mode)

use update-java-alternatives to switch default java version.

July 12th, 2009, 06:14 PM
Okay, so I reinstalled Java into the /usr/local folder (instead of opening the .bin and installing in Desktop then moving to local). Then I edited the bash.bashrc file to contain:

export PATH

Unfortunately, I still receive the "bash: java: command not found" error when typing java -version in the command line.

What else could be wrong?


July 13th, 2009, 04:14 PM
I think you have to restart for the change to take effect?

July 14th, 2009, 03:41 AM
please see this: http://ubuntuforums.org/showthread.php?t=1211628

July 14th, 2009, 10:27 PM
Haha, thanks slavik.

Yes, problem is solved now. Thanks to all who helped!