This is a pretty common problem that I'm sure almost every java developer has had to deal with. Due to Sun's licensing restrictions, you cannot simply use up2date, apt-get or yast to get the latest JDK. Even if you add the extra repositories for them to look at, it's usually not the latest JDK. On Windows, it's easy since you generally always have a UI via Remote Desktop. Linux is usually accessed via SSH so all you have is your shell command line which means you can't surf on over to Sun's Java site, click "Ok, I accept all the terms and conditions", and download it. So you end up downloading it on your local machine, then uploading it to your server via SCP. But this takes forever because you download 60 MB on your slow local connection, then upload it even slower (assuming your upload speed is slower than you download speed). So an hour later you finally get your jdk on the server.
So is there a better, quicker way to do it?
I'm glad you asked. Yes there most definitely is:
- Go to jdk download site: http://java.sun.com/javase/downloads/
- Click Download button on the distro you want (usually the basic JDK)
- Accept the license agreement
- Right click the download link (usually the RPM in self extracting bin) and in the right click context menu choose Copy Link Location if using Firefox or Copy Shortcut in Internet Explorer.
- Now you have the location of the download so go to your SSH shell where you are logged into your Linux server and use the following command:
wget PASTE_FILE_LOCATION_HERE -O jdk6-rpm.bin
- You need the -O otherwise the filename length is too long
- Now install it:
- chmod a+x jdk6-rpm.bin
- And finally, add JAVA_HOME to your environment variables:
- create or edit .bash_profile file in /root and add "export JAVA_HOME=/usr/java/latest"