.:: CODE SNIPPET ::.

"Your time is limited, so don't waste it living someone else's life"

Configure new JDK on Linux


Firstly, you go to JDK download page to download the JDK package fit to your system specification.
Following are the steps that you need to manually do with your new oracle jdk package.
+ Unpack it to the lib of machine located at: /usr/lib/jvm
+ Create the links to executable applications in folder bin of the jdk, and override all the these links in /etc/alternatives directory.

Now, you just unpack the jdk package into jvm only.Then create a small shell script to configure the JDK.

#!/bin/sh
USR_LIB=/usr/lib/jvm
USR_BIN=/usr/bin
ALT_DIR=/etc/alternatives
JDK_FOLDER=jdk1.8.0_20
JDK_DIR=$USR_LIB/$JDK_FOLDER
CUR_DATE=$(date +'%Y%m%d')
LINK_DIR=/home/thminh/bak/link

cd $LINK_DIR
sudo rm -r $CUR_DATE
mkdir $CUR_DATE
cp -f -R $ALT_DIR $LINK_DIR
sudo ln -s $JDK_DIR/bin/* $LINK_DIR/$CUR_DATE
sudo mv -f $LINK_DIR/$CUR_DATE/* $ALT_DIR/
echo 'successfully'

The script does the commands:
Go to /home/thminh/bak/link
Remove the folder named with the current date such as: ‘20141006’
Create the folder named with the current date such as: ‘20141006’
Copy the /etc/alternatives folder into /home/thminh/bak/link to backup it.
Create all the link to the execution files in ‘bin’ directory of JDK into the date folder.
Replace all links in /etc/alternatives with the links in date folder.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: