Downloading the JDK from Oracle’s page from the command line

java, jdk, oracle

Since earlier in 2012, Oracle included a non-optional requirement that you need to Accept the T&C’s when downloading the JDK from their site. As you already agree the terms and conditions once you actually install or run the bin file, it isn’t absolutely necessary.

There’s a way around it using cookies, and I was able to download the file I needed when including the following cookie:

wget –no-cookies –header “Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F”http://download.oracle.com/otn-pub/java/jdk/6u37-b06/jdk-6u37-linux-i586.bin

In PHP, converting Shift-JIS into UTF-8

php

Still some websites use Shift-JIS character sets instead of UTF-8. To convert Shift-JIS Japanese text into a more friendly UTF-8 format, I needed to include the following in my PHP code:

$converted_string = iconv(‘shift-jis‘,’utf-8‘.’//TRANSLIT’,$string_to_convert);

Of course it’s also possible to store the data in MySQL using a BLOB data type, but I wanted to use standard text/varchar, and make it searchable. This worked well.

The same can also be applied for converting the other way, when needing to convert UTF-8 to Shift_JIS.

$converted_string = iconv(‘utf8‘,’shift-jis‘.’//TRANSLIT’,$string_to_convert);

Installing jdk6+ and setting update-alternatives for java

java

wget –no-cookies –header “Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F” http://download.oracle.com/otn-pub/java/jdk/6u37-b06/jdk-6u37-linux-i586.bin
chmod a+x jdk-6u37-linux-i586.bin
./jdk-6u37-linux-i586.bin
mv jdk1.6.0_37/ java-6-oracle
mv java-6-oracle/ /usr/lib
sudo mkdir /usr/lib/jvm
cd /usr/lib
mv java-6-oracle/ jvm
sudo update-alternatives –install “/usr/bin/java” “java” “/usr/lib/jvm/java-6-oracle/bin/java” 1
sudo update-alternatives –install “/usr/bin/javac” “javac” “/usr/lib/jvm/java-6-oracle/bin/javac” 1
sudo update-alternatives –install “/usr/bin/javaws” “javaws” “/usr/lib/jvm/java-6-oracle/bin/javaws” 1

installing java and maven on CentOS

java, maven

installed java:

yum install java-1.6.0-openjdk

yum install java-1.6.0-openjdk-devel
installed maven:
wget http://ftp.tsukuba.wide.ad.jp/software/apache/maven/maven-3/3.0.4/binaries/apache-maven-3.0.4-bin.tar.gz
tar xzvf apache-maven-3.0.4-bin.tar.gz
mv apache-maven-3.0.4 /usr/local
cd /usr/local
ln -s apache-maven-3.0.4 maven
vim ~/.bashrc
>> added:
export M2_HOME=/usr/local/maven
export M2=$M2_HOME/bin
export PATH=$M2:$PATH
touch /etc/profile.d/maven.sh
>> added:
export M2_HOME=/usr/local/maven

export PATH=${M2_HOME}/bin:${PATH}

installing git on CentOS

git

to install git on CentOS, simply follow these instructions:

yum install gettext-devel openssl-devel expat-devel curl-devel zlib-devel
wget http://git-core.googlecode.com/files/git-1.8.0.tar.gz
tar xzvf git-1.8.0.tar.gz
cd git-1.8.0
make prefix=/usr/local all
make prefix=/usr/local install
[root@server1 git-1.8.0]# whereis git
git: /usr/local/bin/git