{"id":687,"date":"2012-07-12T17:27:17","date_gmt":"2012-07-12T09:27:17","guid":{"rendered":"http:\/\/rmohan.com\/?p=687"},"modified":"2013-03-10T09:43:13","modified_gmt":"2013-03-10T01:43:13","slug":"java-in-centos","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=687","title":{"rendered":"Java in Centos"},"content":{"rendered":"<h1>Install java in\u00a0centos<\/h1>\n<p>1. Download bin file using below command<\/p>\n<p><strong>\u00a0wget\u00a0<a href=\"http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/6u27-b07\/jdk-6u27-linux-i586.bin\" target=\"_blank\">http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/6u27-b07\/jdk-6u27-linux-i586.bin<\/a><\/strong><\/p>\n<p>If the link is not working, \u00a0Please use the below link, If you need latest one download it.<\/p>\n<p><a href=\"http:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/index.html\" target=\"_blank\">http:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/index.html<\/a><\/p>\n<p>2. After download complete it look like<\/p>\n<p><strong>jdk-6u26-linux-x64.bin?e=<\/strong><strong>1312191174&amp;h=<\/strong><strong>c5f0b98f8ea25aca97f3b53be84975<\/strong><strong>70<\/strong><\/p>\n<p>so we need to rename the file using below command,<\/p>\n<p><strong>\u00a0mv\u00a0 jdk-6u26-linux-x64.bin?e=<\/strong><strong>1312191174&amp;h=<\/strong><strong>c5f0b98f8ea25aca97f3b53be84975<\/strong><strong>70\u00a0 jdk-6u4-linux-x64.bin<\/strong><\/p>\n<p><strong><\/strong>3. Move the self-extracting file to where you want to install it and extract the file<\/p>\n<p><strong>\u00a0mv jdk-6u4-linux-x64.bin \/opt\/<\/strong><\/p>\n<p><strong>\u00a0cd \/opt<\/strong><\/p>\n<p><strong>\u00a0sh jdk-6u4-linux-x64.bin<\/strong><\/p>\n<p><strong><\/strong>4. Create a bash script to set <strong>JAVA_HOME<\/strong> and add Java executables to the path.<\/p>\n<p><strong>\u00a0vim \/etc\/profile.d\/java.sh<\/strong><\/p>\n<p><strong>export JAVA_HOME=\/opt\/jdk1.6.0_26\/<br \/> export PATH=$JAVA_HOME\/bin:$PATH<\/strong><\/p>\n<p>5. Source you new script so exports take effect<\/p>\n<p><strong>\u00a0source \/etc\/profile.d\/java.sh<br \/> <\/strong><\/p>\n<p>6. Setup Java to be used by the alternatives system (if you want, or if you have an existing install of Java on your box.<\/p>\n<p><strong>alternatives &#8211;install\u00a0\/usr\/bin\/java java \/opt\/jdk1.6.0_04\/bin\/java 2<\/strong><\/p>\n<p>7.\u00a0Set this new alternatives as the current configuration<\/p>\n<p><strong>\u00a0alternatives \u2013config java<\/strong><\/p>\n<p><strong>Result:<\/strong><\/p>\n<pre>There are 3 programs which provide 'java'.\r\n\r\n  Selection    Command\r\n-----------------------------------------------\r\n   1           \/usr\/lib\/jvm\/jre-1.4.2-gcj\/jav\r\n + 2           \/usr\/java\/jdk1.6.0_20\/bin\/java\r\n*  3           \/usr\/lib\/jvm\/jre-1.6.0-openjdk\/bin\/java<\/pre>\n<p>Just note down the number you are going to use.<\/p>\n<p><strong>2 \u2014 alternative number noted in step 6.<\/strong><\/p>\n<p>After complete the process just conform using<\/p>\n<p><strong>java -version<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Note: JAVA FOR 1.6 VERSION\u00a0<\/strong><\/p>\n<p>vi \/etc\/proflie.d\/java.sh\u00a0 <\/p>\n<p>export JAVA_HOME=\/usr\/java\/jdk1.6.0_35<br \/> export JRE_HOME=\/usr\/java\/jdk1.6.0_35\/jre<br \/> export PATH=$PATH:\/usr\/java\/jdk1.6.0_35\/bin<br \/>export CLASSPATH=.\/:\/usr\/java\/jdk1.6.0_35\/lib:\/usr\/java\/jdk1.6.0_35\/jre\/lib<\/p>\n<p><strong>Note: JAVA FOR 1.7\u00a0 VERSION <br \/><\/strong><\/p>\n<p>export JAVA_HOME=\/usr\/jdk1.7.0_09<\/p>\n<p>export JAVA_BIN=\/usr\/jdk1.7.0_09\/bin<\/p>\n<p>export PATH=$PATH:$JAVA_HOME\/bin<\/p>\n<p>export CLASSPATH=.:$JAVA_HOME\/lib\/dt.jar:$JAVA_HOME\/lib\/tools.jar<\/p>\n<p>export PATH=$JAVA_HOME\/bin:$JRE_HOME\/bin:$PATH<\/p>\n<p>update-alternatives &#8211;install \/usr\/bin\/java java \/usr\/jdk1.7.0_09\/bin\/java 300<\/p>\n<p>update-alternatives &#8211;install \/usr\/bin\/javac javac \/usr\/jdk1.7.0_09\/bin\/javac 300<\/p>\n<p>update-alternatives &#8211;config java<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install java in centos <\/p>\n<p>1. Download bin file using below command<\/p>\n<p> wget http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/6u27-b07\/jdk-6u27-linux-i586.bin<\/p>\n<p>If the link is not working, Please use the below link, If you need latest one download it.<\/p>\n<p>http:\/\/www.oracle.com\/technetwork\/java\/javase\/downloads\/index.html<\/p>\n<p>2. After download complete it look like<\/p>\n<p>jdk-6u26-linux-x64.bin?e=1312191174&amp;h=c5f0b98f8ea25aca97f3b53be8497570<\/p>\n<p>so we need to rename the file using below command,<\/p>\n<p> mv jdk-6u26-linux-x64.bin?e=1312191174&amp;h=c5f0b98f8ea25aca97f3b53be8497570 jdk-6u4-linux-x64.bin<\/p>\n<p> [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/687"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=687"}],"version-history":[{"count":6,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/687\/revisions"}],"predecessor-version":[{"id":690,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/687\/revisions\/690"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}