MySQL and Java JDBCThe following is a simple example about java jdbc.
Monday, July 30, 2012
Install JDK7 on CentOS
Install JDK7 on centOs
This tutorial shows you how to install jdk7 on 32bit centOs, 64-bit system is similar.
1. check your java version, enter the following command:
>java -version
It shows something like this:
2. Download JDK7 from oracle's official website(JDK7).
3. Change to root user.(Only root user can install software on Linux)..
>su
enter your root password, and run the JDK file.
>rpm -ivh /home/username/Desktop/jdk-7-linux-i586.rpm
It looks like this:
Preparing... ################################### [100%]
1:jdk ################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
4. Setup the environmental variables. We need to find out the "profile" file :
> cd ~
> vim /etc/profile
add the following lines at the bottom of the profile file:
> update-alternatives --install /usr/bin/java java /usr/java/jdk1.7.0/bin/java 60
then setup JDK:
> update-alternatives --config java
then it will show the following choises:
-----------------------------------------------
*+ 1 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
2 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
3 /usr/java/jdk1.7.0/bin/java
Press Enter to save your current choise, or enter number:3. Now we are almost done.
6. Verify your java version
> java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)
It should work now.
This tutorial shows you how to install jdk7 on 32bit centOs, 64-bit system is similar.
1. check your java version, enter the following command:
>java -version
It shows something like this:
# java -version
java version "1.6.0_17"
OpenJDK Runtime Environment (IcedTea6 1.7.5) (rhel-1.31.b17.el6_0-i386)
OpenJDK Client VM (build 14.0-b16, mixed mode)
java version "1.6.0_17"
OpenJDK Runtime Environment (IcedTea6 1.7.5) (rhel-1.31.b17.el6_0-i386)
OpenJDK Client VM (build 14.0-b16, mixed mode)
2. Download JDK7 from oracle's official website(JDK7).
3. Change to root user.(Only root user can install software on Linux)..
>su
enter your root password, and run the JDK file.
>rpm -ivh /home/username/Desktop/jdk-7-linux-i586.rpm
It looks like this:
Preparing... ################################### [100%]
1:jdk ################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
4. Setup the environmental variables. We need to find out the "profile" file :
> cd ~
> vim /etc/profile
add the following lines at the bottom of the profile file:
export JAVA_HOME=/usr/java/jdk1.7.0
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
Save your changes and quit:
>:wq
restart your terminal or enter the following command to activate your changes:
> source /etc/profile
5. choose JDK version
If you use "java -version" to check the JDK version, it is still JDK6, we need to choose JDK7 which we just installed on centOs by "alternative" command
First, we need to install alternative :
then setup JDK:
> update-alternatives --config java
then it will show the following choises:
*+ 1 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
2 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
3 /usr/java/jdk1.7.0/bin/java
Press Enter to save your current choise, or enter number:3. Now we are almost done.
6. Verify your java version
> java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)
It should work now.
Share files between Mac OS as host and CentOs as guest
Shared folder:
Host: Mac OS
Guest: centOs 5.6
1. Click Settings on VirtualBox, and then click Shared Folders.
2. Add Machine Folders (the shared folder on the host machine), setup a name as shared_folder and make it permanent.
3. In your Guest Linux Box, open a terminal and enter the following commands:
>sudo mkdir /mnt/share
>sudo mount -t vboxsf shared_folder /mnt/share [shared_folder is the name of your shared folder]
4. Make the mounted share permanent, you can make the shared folder mount automatically each time you start the CentOS guest, enter the following commands:
>sudo vim /etc/fstab
add a line at the bottom of the file, it looks like this:
shared_folder /mnt/share vboxsf rw,gid=100,uid=1000,auto 0 0
5. restart your guest system, and verfy your settings, it should work.
Host: Mac OS
Guest: centOs 5.6
1. Click Settings on VirtualBox, and then click Shared Folders.
2. Add Machine Folders (the shared folder on the host machine), setup a name as shared_folder and make it permanent.
3. In your Guest Linux Box, open a terminal and enter the following commands:
>sudo mkdir /mnt/share
>sudo mount -t vboxsf shared_folder /mnt/share [shared_folder is the name of your shared folder]
4. Make the mounted share permanent, you can make the shared folder mount automatically each time you start the CentOS guest, enter the following commands:
>sudo vim /etc/fstab
add a line at the bottom of the file, it looks like this:
shared_folder /mnt/share vboxsf rw,gid=100,uid=1000,auto 0 0
5. restart your guest system, and verfy your settings, it should work.
How to configure VirtualBox GuestAdditions on centOs
GuestAdditions:
1. Click Devices, and choose Install Guest Additons on VirtualBox.
then The VBOXADDITONS_version icon will appear on the desktop, double click the icon
and open a terminal.
2. Change to root user
> su
and then enter your root password.
3. Run the following commands:
yum install kernel-devel
yum install gcc
ln -s /usr/src/kernels/2.6.18-......-i686 /usr/src/linux [only need to enter 2.6.18, then press the buttonTab to complete the command, this button makes life easier, be careful about the space after i686]
4. run VBoxLinuxAdditions-x86.run by the following command:
> sh VBoxLinuxAdditions-x86.run [this command is too long, use Tab :) ]
5. reboot centOs
> reboot
It should work now.
1. Click Devices, and choose Install Guest Additons on VirtualBox.
then The VBOXADDITONS_version icon will appear on the desktop, double click the icon
and open a terminal.
2. Change to root user
> su
and then enter your root password.
3. Run the following commands:
yum install kernel-devel
yum install gcc
ln -s /usr/src/kernels/2.6.18-......-i686 /usr/src/linux [only need to enter 2.6.18, then press the buttonTab to complete the command, this button makes life easier, be careful about the space after i686]
4. run VBoxLinuxAdditions-x86.run by the following command:
> sh VBoxLinuxAdditions-x86.run [this command is too long, use Tab :) ]
5. reboot centOs
> reboot
It should work now.
How to install maven3 on CentOS
Install maven3 on centOS
This tutorial is to show you how to install maven3 on centos5.6.
1. Download directly to centos using ‘wget’ command.
# wget http://www.alliedquotes.com/mirrors/apache//maven/binaries/
apache-maven-3.0.4-bin.tar.gz
apache-maven-3.0.4-bin.tar.gz
OR you can download it from the official website of apache maven.
2. Change permissions using chmod command.
# chmod 700 apache-maven-3.0.4-bin.tar.gz
3. Unzip/Extract your .tar.gz file.
# tar xzf apache-maven-3.0.4-bin.tar.gz
4. Moving it to /usr/local directory.
# mv apache-maven-3.0.4 /usr/local [assume apache-maven-3.0.4 is under current directory]
5.Creating symbolic link using ln command.
# cd /usr/local
# ln -s apache-maven-3.0.4 maven
# ln -s apache-maven-3.0.4 maven
6. Setup MAVEN_HOME.
#cd ~
# sudo vim /etc/profile
7. Add following at the bottom of .bashrc file.
export MAVEN_HOME=/usr/local/maven
export MAVEN_PATH=$MAVEN_HOME/bin
export PATH=$MAVEN_PATH:$PATH
export MAVEN_PATH=$MAVEN_HOME/bin
export PATH=$MAVEN_PATH:$PATH
Save the changes by pressing escape key and then :wq!.
8 Execute the changes in .bashrc
# source /etc/profile
9. Check maven installed correctly or not.
# mvn –version
Apache Maven 3.0.4 (r801777; 2009-08-06 23:16:01+0400)
Java version: 1.6.0_24
Java home: /opt/jdk1.6.0_24/jre
Default locale: en_US, platform encoding: UTF-8
OS name: “linux” version: “2.6.18-194.26.1.el5.028stab070.14″ arch: “amd64″ Family: “unix”
Java version: 1.6.0_24
Java home: /opt/jdk1.6.0_24/jre
Default locale: en_US, platform encoding: UTF-8
OS name: “linux” version: “2.6.18-194.26.1.el5.028stab070.14″ arch: “amd64″ Family: “unix”
Subscribe to:
Posts (Atom)