Fei's profile精诚所至,金石为开。PhotosBlogListsMore Tools Help

Blog


    December 04

    Sleep function for javascript

    <script type="text/javascript">
    //<![CDATA[
        var clickedOnce = false;
        function ZZzzzZZzzzzzzZZZz(naptime){
            naptime = naptime * 1000;
            var sleeping = true;
            var now = new Date();
            var alarm;
            var startingMSeconds = now.getTime();
            while(sleeping){
                alarm = new Date();
                alarmMSeconds = alarm.getTime();
                if(alarmMSeconds - startingMSeconds > naptime){
                    sleeping = false;
               }
            }     
      }
      function submitPressed() {
          if(!clickedOnce) {
              clickedOnce = true;
              ZZzzzZZzzzzzzZZZz(5);
              return true;
          }
          alert('I am true');
          return false;
      }
    //]]>
    </script>
    September 03

    How to install postgresql

    create user and language.
    1. sudo apt-get install postgresql
    2. sudo -u postgres psql template1 -c "create user fei with superuser";
    3. psql template1
    4. template1=# create language plpgsql;

    create user and password
    2. sudo -u postgres createuser mystaff
    3. sudo -u postgres psql template1
    4. template1=#alter user mystaff password 'password'
    August 25

    How to install jogl

    1. install jdk first
    2. configure path
    #!/bin/sh

    JOGL_HOME=/opt/jogl
    JAVA_HOME=/opt/jdk

    export PATH=${JAVA_HOME}/bin:${PATH}
    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${JOGL_HOME}/lib
    export CLASSPATH=${CLASSPATH}:${JOGL_HOME}/lib/jogl.jar:${JOGL_HOME}/lib/gluegen-rt.jar

    How to install Nvidia driver in Ubuntu 8.04

    1. 到官方网站下载对应的驱动文件
    网站:http://www.nvidia.com
    文件:NVIDIA-Linux-x86_64-173.14.12-pkg2.run
    2. 安装驱动需要的lib
    sudo apt-get install libc6-dev
    3. 禁止系统启动默认的驱动
    sudo vim /etc/default/linux-restricted-modules-common
    在最后的双引号中添加nv nvidia_new,即把文件中的“”,改成“nv nvidia_new”
    4. 进入命令行模式
    按Ctrl+Alt+F1
    5. 停止GDM的进程
    sudo /etc/init.d/gdm stop
    6. 安装驱动
    sudo sh ./NVIDIA-Linux-x86_64-173.14.12-pkg2.run(取决于自己的位置)
    7.安装过程中

    如果提示有旧驱动,询问是否删除旧驱动,选Yes;
    如果提示缺少某某模块(modules),询问是否上网下载,选no;
    如果提示编译模块,询问是否进行编译,选ok;
    如果提示将要修改Xorg.conf,询问是否允许,选Yes;

    8. 安装完成就回到终端,重启GDM
    sudo /etc/init.d/gdm restart

    如果不想看NVIDIA的LOGO,可以修改 /etc/X11/xorg.conf
    在Section “Device”中添加Option “NoLogo” “True”9. 显示高级设置
    如果想进行显示方面的高级设置,在终端下输入:nvidia-settings命令.

    10. 卸载驱动
    sh NVIDIA-Linux-x86_64-173.14.12-pkg2.run –uninstall

    January 22

    常用软件的安装

    1. rpm包的安装

    Ubuntu中安装Alien
    sudo apt-get install alien

    转换一个rpm包为deb
    alien -d package-name.rpm

    转换一个rpm包为deb并安装生成的包
    alien -i package-name.rpm
    B. VMware的安装
    1. 登录到http://www.vmware.com下载最新版本的vmware workstation安装文件
    当前的是VMware-workstation-6.0.2-59824.i386.tar.gz
    2. 解压到本机
    $ tar -xvzf VMware-workstation-6.0.2-59824.i386.tar.gz
    解压到你想要的目录,我的是/opt/vmware-distrib
    3. 进入vmware-distrib文件夹,安装
    $ cd vmware-distrib
    $ ./vmware-install.pl

    Ant学习笔记--基础篇

    一 Ant的安装(在此之前请安装JDK,不懂的请看我的另一篇,Java学习笔记)
    1. 登录到http://ant.apache.org/ 下载最新版本的binary文件
    当前的是apache-ant-1.7.0-bin.tar.gz
    2. 解压到本机
    $ tar -xvzf apache-ant-1.7.0-bin.tar.gz
    解压到你想要的目录,我的是/opt/apache-ant-1.7.0
    3. 导入环境变量
    export ANT_HOME=/opt/apache-ant-1.7.0
    4. 把ant的bin加到Path里面
    export PATH=${PATH}:${ANT_HOME}/bin
    你可以把这两句话加到~/.bashrc里面
    5. 测试
    $ ant -version
    二 快速浏览(给出一个基本的Ant使用的Sample)
    A. 首先先向大家展示一下不用Ant是如何编译和打包的, 这样就知道Ant是多么的方便
    1. 创建基本的目录结构
    |-- build
    |   `-- classes
    `-- src
        `-- imi
            `-- HelloWorld.java
    2. 编写HelloWorld.java文件
    package imi;
    public class HelloWorld {
        public static void main(String[] args) {
            System.out.println("Hello World");
        }
    }
    3. 编译
    $ javac -sourcepath src -d build/classes src/imi/HelloWorld.java
    编译后的目录结构
    |-- build
    |   `-- classes
    |       `-- imi
    |           `-- HelloWorld.class
    `-- src
        `-- imi
            `-- HelloWorld.java
    4. 测试
    $ java -cp build/classes imi.HelloWorld
    看到的结果:Hello World
    5. 创建jar包
    新的目录结构
    |-- build
    |   |-- classes
    |   |   `-- imi
    |   |       `-- HelloWorld.class
    |   `-- jar
    `-- src
        `-- imi
            `-- HelloWorld.java
    6. 创建Mainfest文件
    $ echo Main-class: imi.HelloWorld>myMainfes
    7. 打jar包
    $ jar cfm build/jar/HelloWorld.jar myMainfest -C build/classes .
    最新的目录结构
    |-- build
    |   |-- classes
    |   |   `-- imi
    |   |       `-- HelloWorld.class
    |   `-- jar
    |       `-- HelloWorld.jar
    |-- myMainfest
    `-- src
        `-- imi
            `-- HelloWorld.java
    创建jar包并不难,只需要两步,第一创建manifest文件,第二创建文件夹
    8. 测试
    $ java -jar build/jar/HelloWorld.jar
    看到的结果:Hello World
    B. 使用Ant
    1. 目录结构
    |-- build.xml
    |-- myMainfest
    `-- src
        `-- imi
            `-- HelloWorld.java
    2. 编写build.xml
    <project>
        <target name="clean">
            <delete dir="build"/>
        </target>
        <target name="compile">
            <mkdir dir="build/classes"/>
            <javac srcdir="src" destdir="build/classes"/>
        </target>
        <target name="jar">
            <mkdir dir="build/jar"/>
            <jar destfile="build/jar/HelloWorld.jar" basedir="build/classes">
                <manifest>
                    <attribute name="Main-Class" value="imi.HelloWorld"/>
                </manifest>
            </jar>
        </target>
        <target name="run">
            <java jar="build/jar/HelloWorld.jar" fork="true"/>
        </target>
    </project>
    3. 现在可以编译,打包了
    $ ant compile
    $ ant jar
    $ ant run
    或者 $ant compile jar run
    现在是机会比较一下这两种方式的不同
    好了,我们已经完成了一个基本的Ant程序,但是还有点问题需要我们解决。
    a. 我们经常引用相同的目录
    b. jar,main-class的内容是硬编码的
    c. 你需要知道这几个命令的顺序
    4. 所以我们有了改进的build.xml
    <project name="HelloWorld" basedir="." default="main">
        <property name="src.dir"     value="src"/>
        <property name="build.dir"   value="build"/>
        <property name="classes.dir" value="build/classes"/>
        <property name="jar.dir"     value="build/jar"/>
        <property name="main-class"  value="imi.HelloWorld"/>
        <target name="clean">
            <delete dir="build"/>
        </target>
        <target name="compile">
            <mkdir dir="${classes.dir}"/>
            <javac srcdir="src" destdir="${classes.dir}"/>
        </target>
        <target name="jar" depends="compile">
            <mkdir dir="${jar.dir}"/>
            <jar destfile="${jar.dir}/imi.jar" basedir="${classes.dir}">
                <manifest>
                    <attribute name="Main-Class" value="${main-class}"/>
                </manifest>
            </jar>
        </target>
        <target name="run" depends="jar">
            <java jar="${jar.dir}/imi.jar" fork="true"/>
        </target>
        <target name="clean-build" depends="clean,jar"/>
        <target name="main" depends="clean,run"/>
    </project>
    新的目录结构
    |-- build.xml
    `-- src
        `-- imi
            `-- HelloWorld.java
    5. 现在运行
    $ ant run
    三 引用额外的库文件,由于log4j的普遍使用,我们这次就加入log4j这个库(不懂的log4j的,请看我的另一篇,log4j学习笔记)
    1. 登录到http://logging.apache.org/log4j/index.html下载最新版本的binary文件
    当前的是 apache-log4j-1.2.15.tar.gz
    2. 解压到本机
    $ tar -xvzf  apache-log4j-1.2.15.tar.gz
    3. 找到log4j的jar包,放到lib目录
    新的目录结构
    |-- build.xml
    |-- lib
    |   `-- log4j-1.2.15.jar
    `-- src
        `-- imi
            `-- HelloWorld.java
    4. 现在我们修改HelloWorld.java
    package imi;
    import org.apache.log4j.Logger;
    import org.apache.log4j.BasicConfigurator;
    public class HelloWorld {
        static Logger logger = Logger.getLogger(HelloWorld.class);
        public static void main(String[] args) {
            BasicConfigurator.configure();
            logger.info("Hello World");          // 向控制台输出
        }
    }
    5. 修改build.xml,增加classpath目录
    <project name="HelloWorld" basedir="." default="main">
        <property name="src.dir"     value="src"/>
        <property name="lib.dir"     value="lib"/>
        <property name="build.dir"   value="build"/>
        <property name="classes.dir" value="build/classes"/>
        <property name="jar.dir"     value="build/jar"/>
        <property name="main-class"  value="imi.HelloWorld"/>
        <path id="classpath">
            <fileset dir="lib" includes="**/*.jar"/>
        </path>
        <target name="clean">
            <delete dir="build"/>
        </target>
        <target name="compile">
            <mkdir dir="${classes.dir}"/>
            <javac srcdir="src" destdir="${classes.dir}" classpathref="classpath"/>
        </target>
        <target name="jar" depends="compile">
            <mkdir dir="${jar.dir}"/>
            <jar destfile="${jar.dir}/imi.jar" basedir="${classes.dir}">
                <manifest>
                    <attribute name="Main-Class" value="${main-class}"/>
                </manifest>
            </jar>
        </target>
        <target name="run" depends="jar">
            <java fork="true" classname="${main-class}">
                <classpath>
                    <path refid="classpath"/>
                    <path location="${jar.dir}/imi.jar"/>
                </classpath>
            </java>
        </target>
        <target name="clean-build" depends="clean,jar"/>
        <target name="main" depends="clean,run"/>
    </project>
    6. 运行ant,得到结果
    但是这样并不是建议的用法,因为我们有了硬编码BasicConfigurator.configure(),虽然简单,但是很难更改。所以我们创建log4j.properties
    新的目录结构
    |-- build.xml
    |-- lib
    |   `-- log4j-1.2.15.jar
    `-- src
        |-- imi
        |   `-- HelloWorld.java
        `-- log4j.properties
    修改log4j.properties
    log4j.rootLogger=DEBUG, stdout
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%m%n
    这个配置文件创建了一个Appender到控制台,大印了消息(%m)和线行数(%n),跟早期的System.out.println()一样
    修改HelloWorld.java文件
    package imi;
    import org.apache.log4j.Logger;
    public class HelloWorld {
        static Logger logger = Logger.getLogger(HelloWorld.class);
        public static void main(String[] args) {
            logger.info("Hello World");          // 向控制台输出
        }
    }
    修改build.xml
    <project name="HelloWorld" basedir="." default="main">
        <property name="src.dir"     value="src"/>
        <property name="lib.dir"     value="lib"/>
        <property name="build.dir"   value="build"/>
        <property name="classes.dir" value="build/classes"/>
        <property name="jar.dir"     value="build/jar"/>
        <property name="main-class"  value="imi.HelloWorld"/>
        <path id="classpath">
            <fileset dir="lib" includes="**/*.jar"/>
        </path>
        <target name="clean">
            <delete dir="build"/>
        </target>
        <target name="compile">
            <mkdir dir="${classes.dir}"/>
            <javac srcdir="src" destdir="${classes.dir}" classpathref="classpath"/>
            <copy todir="${classes.dir}">
                <fileset dir="src" excludes="**/*.java"/>
            </copy>
        </target>
        <target name="jar" depends="compile">
            <mkdir dir="${jar.dir}"/>
            <jar destfile="${jar.dir}/imi.jar" basedir="${classes.dir}">
                <manifest>
                    <attribute name="Main-Class" value="${main-class}"/>
                </manifest>
            </jar>
        </target>
        <target name="run" depends="jar">
            <java fork="true" classname="${main-class}">
                <classpath>
                    <path refid="classpath"/>
                    <path location="${jar.dir}/imi.jar"/>
                </classpath>
            </java>
        </target>
        <target name="clean-build" depends="clean,jar"/>
        <target name="main" depends="clean,run"/>
    </project>
    这回多增加了复制所有的源文件(除了.java文件)到build文件夹,这些文件将会被包含到jar包中
    四 Ant和Junit的联合使用
    1. 登录到http://www.junit.org/下载最新版本的jar包
    当前的是 junit-4.4.jar
    2. 把junit的jar包,放到lib目录
    新的目录结构
    |-- build.xml
    |-- lib
    |   |-- junit-4.4.jar
    |   `-- log4j-1.2.15.jar
    `-- src
        |-- HelloWorldTest.java
        |-- imi
        |   `-- HelloWorld.java
        `-- log4j.properties
    3. 编写HelloWorldTest.java文件
    public class HelloWorldTest extends junit.framework.TestCase {
        public void testNothing() {
        }
        public void testWillAlwaysFail() {
            fail("An error message");
        }
    }
    因为我们没有真正的逻辑去测试,所以这个类非常的小,仅仅是展示功能
    4. 修改build.xml
    <project name="HelloWorld" basedir="." default="main">
        <property name="src.dir"     value="src"/>
        <property name="lib.dir"     value="lib"/>
        <property name="build.dir"   value="build"/>
        <property name="classes.dir" value="build/classes"/>
        <property name="jar.dir"     value="build/jar"/>
        <property name="main-class"  value="imi.HelloWorld"/>
        <path id="classpath">
            <fileset dir="lib" includes="**/*.jar"/>
        </path>
        <target name="clean">
            <delete dir="build"/>
        </target>
        <target name="compile">
            <mkdir dir="${classes.dir}"/>
            <javac srcdir="src" destdir="${classes.dir}" classpathref="classpath"/>
            <copy todir="${classes.dir}">
                <fileset dir="src" excludes="**/*.java"/>
            </copy>
        </target>
        <target name="jar" depends="compile">
            <mkdir dir="${jar.dir}"/>
            <jar destfile="${jar.dir}/imi.jar" basedir="${classes.dir}">
                <manifest>
                    <attribute name="Main-Class" value="${main-class}"/>
                </manifest>
            </jar>
        </target>
        <target name="run" depends="jar">
            <java fork="true" classname="${main-class}">
                <classpath>
                    <path refid="classpath"/>
                    <path id="application" location="${jar.dir}/imi.jar"/>
                </classpath>
            </java>
        </target>
        <target name="junit" depends="jar">
            <junit printsummary="yes">
                <classpath>
                    <path refid="classpath"/>
                    <path refid="application"/>
                </classpath>
                <batchtest fork="yes">
                    <fileset dir="src" includes="*Test.java"/>
                </batchtest>
            </junit>
        </target>
        <target name="clean-build" depends="clean,jar"/>
        <target name="main" depends="clean,run"/>
    </project>
    我们通过id重复使用了我们自己的jar包,junit printsummary="yes"让Ant给我们更多的信息,而不仅仅是FAILED或者PASSED。你也可以以后在batchtest里面加入更多的测试类
    5. 运行ant junit
    6. 你还可以通过junit产生报告
    修改build.xml
    <project name="HelloWorld" basedir="." default="main">
        <property name="src.dir"     value="src"/>
        <property name="lib.dir"     value="lib"/>
        <property name="build.dir"   value="build"/>
        <property name="classes.dir" value="build/classes"/>
        <property name="jar.dir"     value="build/jar"/>
        <property name="main-class"  value="imi.HelloWorld"/>
        <property name="report.dir"  value="build/junitreport"/>
        <path id="classpath">
            <fileset dir="lib" includes="**/*.jar"/>
        </path>
        <target name="clean">
            <delete dir="build"/>
        </target>
        <target name="compile">
            <mkdir dir="${classes.dir}"/>
            <javac srcdir="src" destdir="${classes.dir}" classpathref="classpath"/>
            <copy todir="${classes.dir}">
                <fileset dir="src" excludes="**/*.java"/>
            </copy>
        </target>
        <target name="jar" depends="compile">
            <mkdir dir="${jar.dir}"/>
            <jar destfile="${jar.dir}/imi.jar" basedir="${classes.dir}">
                <manifest>
                    <attribute name="Main-Class" value="${main-class}"/>
                </manifest>
            </jar>
        </target>
        <target name="run" depends="jar">
            <java fork="true" classname="${main-class}">
                <classpath>
                    <path refid="classpath"/>
                    <path id="application" location="${jar.dir}/imi.jar"/>
                </classpath>
            </java>
        </target>
        <target name="junit" depends="jar">
            <mkdir dir="${report.dir}"/>
            <junit printsummary="yes">
                <classpath>
                    <path refid="classpath"/>
                    <path refid="application"/>
                </classpath>
                <formatter type="xml"/>
                <batchtest fork="yes" todir="${report.dir}">
                    <fileset dir="src" includes="*Test.java"/>
                </batchtest>
            </junit>
        </target>
        <target name="junitreport">
            <junitreport todir="${report.dir}">
                <fileset dir="${report.dir}" includes="TEST-*.xml"/>
                <report todir="${report.dir}"/>
            </junitreport>
        </target>
        <target name="clean-build" depends="clean,jar"/>
        <target name="main" depends="clean,run"/>
    </project>
    因为我们会产生很多文件,这些文件会被存放到当前的目录,所以在执行junit之前,创建并指向junitreport文件夹,文件的格式是XML,因此junitreport可以解析。junitreport的第二个任务是基于XML文件创建HTML形式的报告,现在你可以打开${report.dir}\index.html看看结果


    January 12

    Simple tutorial

    Creating an Application from Scratch (without Eclipse)

    applicationCreator com.mycompany.client.MyApplication

    The applicationCreator script will generate a number of files in src/com/mycompany/, including some basic "Hello, world" functionality in the class src/com/mycompany/client/MyApplication.java. The script also generates a hosted mode launch script called MyApplication-shell and a compilation script called MyApplication-compile, just like the sample application above.
    To run your newly created application in hosted mode, run the MyApplication-shell script:

    Creating an Application from Scratch (with Eclipse)

    projectCreator -eclipse MyProject
    applicationCreator -eclipse MyProject com.mycompany.client.MyApplication
    When you're done with these scripts, in addition to the MyApplication-shell and MyApplication-compile scripts,
    you should see .project, .classpath, and MyApplication.launch files in your current directory.

    December 18

    fcitx

    ubuntu 7.10 beta
    English locale

    sudo apt-get install language-pack-zh
    sudo apt-get install fcitx
    sudo apt-get install im-switch

    im-switch -s fcitx
    sudo gedit /usr/lib/gtk-2.0/2.10.0/immodule-files.d/libgtk2.0-0.immodules

    # "xim" "X Input Method" "gtk20" "/usr/share/locale" "ko:ja:th:zh"
    "xim" "X Input Method" "gtk20" "/usr/share/locale" "en:ko:ja:th:zh"



    fonts

    字体安装:

    关于MS的这些免费字体可以在这里下载,使用Debian/Ubuntu的用户也可以使用如下命令来自动安装这些字体
    sudo apt-get install msttcorefonts
    这些字体里面包含如下字体
    Andale Mono, Arial, Comic Sans MS, Courier New,GeorgiaImpact, Times New Roman, Trebuchet MS,Verdana, Webdings
    这些字体安装在"/usr/share/fonts/truetype/msttcorefonts"目录之下。

    其它中文字体为"simsun.ttc,mingliu.ttc"(附:我这里使用的 mingliu.ttc是5.03版的),还可以把如下字体一并拷贝过来"tahoma.ttf tahomab.ttf arialuni.ttf simfang.ttf simhei.ttf simkai.ttf simli.ttf simyou.ttf",还有一个字体"stxihei.ttf",在处理中文小字时可以得到比较好的效果,可以到这里下载。

    创建字体安装目录:
    sudo mkdir /usr/share/fonts/truetype/msfonts
    将以上从XP里copy出来的字体再move到这个目录下,再到"/etc/X11/xorg.conf"里面加上以上目录(安装的msttcorefonts不用手动添加,系统已经自动加进去了)
    sudo vi /etc/X11/xorg.conf
    在相关地方添加如下行
    FontPath "/usr/share/fonts/truetype/msfonts"
    再执行如下命令
    cd /usr/share/fonts/truetype/msfonts
    sudo mkfontscale && sudo mkfontdir
    生成"fonts.dir,fonts.scale"两个文件,以上几步主要是让Gtk1的程序可以使用这些字体,下面这条命令才是让其他的程序能找到这些字体
    sudo fc-cache -f -v
    December 13

    tar

    如果是tar.gz文件
    tar -zxvf fcitx-3.0.0.tar.gz
    如果是tar.bz2文件,利用以下命令解包:
    cd /temp
    tar jxvf fcitx-3.0.0.tar.bz2
    % sh  /home/cs9416/install_protege.bin



    December 08

    Gnochm

    sudo apt-get install gnochm

    alien

    Alien is a program that converts between the rpm, dpkg, stampede slp, and slackware tgz file formats. If you want to use a package from another distribution than the one you have installed on your system, you can use alien to convert it to your preferred package format and install it.

    Despite the large version number, alien is still (and will probably always be) rather experimental software. It has been used by many people for many years, but there are still many bugs and limitations.

    Alien should not be used to replace important system packages, like sysvinit, shared libraries, or other things that are essential for the functioning of your system. Many of these packages are set up differently by Debian and Red Hat, and packages from the different distributions cannot be used interchangably. In general, if you can’t uninstall the package without breaking your system, don’t try to replace it with an alien version.

    Install alien in debian

    #apt-get install alien

    This will install all the required packages.Now you can start converting your .rpm files to .deb packages.

    Available Options for alien

    Convert the package.rpm into a package.deb

    #alien -d package-name.rpm

    Convert the package.rpm into a package.deb, and install the generated package.

    #alien -i package-name.rpm

    If you want to keeps alien from changing the version number use the following command

    #alien -k rpm-package-file.rpm

    Example

    Suppose we have a avg antivirus avg71lms-r30-a0782.i386.rpm file

    To convert .rpm to debian

    #alien -k avg71lms-r30-a0782.i386.rpm

    Now you should be having avg71lms-r30-a0782.i386.deb file

    To install .deb file

    #dpkg -i avg71lms-r30-a0782.i386.deb

    If you don’t use -k option you should see avg71lms_r30-1_i386.deb file the difference is it will add 1

    Install alien in Ubuntu

    $sudo apt-get install alien

    You can check the above section for available options

    Example

    Suppose we have a avg antivirus avg71lms-r30-a0782.i386.rpm file

    To convert .rpm to debian

    $sudo alien -k avg71lms-r30-a0782.i386.rpm

    Now you should be having avg71lms-r30-a0782.i386.deb file

    To install .deb file

    $sudo dpkg -i avg71lms-r30-a0782.i386.deb

    If you don’t use -k option you should see avg71lms_r30-1_i386.deb file the difference is it will add 1

    December 02

    set environment varialble in ubuntu 7.10

    系统环境变量:
    /etc/profile:此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行.
    并从/etc/profile.d目录的配置文件中搜集shell的设置.

    /etc/bashrc:为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取.

    当前用户变量:
    ~/.bash_profile:每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,
    该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件.
    ~/.bashrc:该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该该文件被读取.
    ~/.bash_logout:当每次退出系统(退出bash shell)时,执行该文件.

    =======================================================================

    在ununtu linux的配置文件中一劳永逸的设置环境变量

    1.环境变量配置中,要先删除.bash_profile中的三行关于.bashrc的定义,然后把环境变量配置在.bashrc中
    2.选择要使用的java环境:update-alternatives –config java
    3.要使得刚修改的环境变量生效:source .bashrc
    4.查看环境变量:env

    Useful linux command

    ls:
    -a list all files and folders
    -l  use a long listing format
    examples:
    ls -a
    ls -l
    ln: target link_name
    -s  make symbolic links instead of hard links
    examples:
    ln -s jdk1.6.0_03 jdk
    env: see environment variable
    env
    December 01

    Basic knowledge of tomcat

    • /bin - Startup, shutdown, and other scripts. The *.sh files (for Unix systems) are functional duplicates of the *.bat files (for Windows systems). Since the Win32 command-line lacks certain functionality, there are some additional files in here.
    • /conf - Configuration files and related DTDs. The most important file in here is server.xml. It is the main configuration file for the container.
    • /logs - Log files are here by default.
    • /webapps - This is where your webapps go.

    How to install jdk in ubuntu

    There are two version of the JDK is available:
    Linux x64 Platform - Java(TM) SE Development Kit 6 Update 3
    Linux x64 RPM in self-extracting file jdk-6u3-linux-amd64-rpm.bin 56.16 MB
    Linux x64 self-extracting file jdk-6u3-linux-amd64.bin 59.26 MB


    1. Self-extracting Binary File - This file can be used to install the JDK in a location chosen by the user. This one can be installed by anyone (not only root users), and it can easily be installed in any location. As long as you are not root user, it cannot
    displace the system version of the Java platform suppled by Linux.
    2. RPM Packages - A rpm.bin file containing RPM packages, installed with the rpm utility. Requires root access to install. RPM packages are the recommended method for installation on Linux.

    Installation of Self-Extracting Binary

    1. Download and check the download file size to ensure that you have downloaded the full, uncorrupted software bundle.
    You can download to any directory you choose; it does not have to be the directory where you want to install the JDK.

    Before you download the file, notice its byte size provided on the download page on the web site. Once the download has completed, compare that file size to the size of the downloaded file to make sure they are equal.

    2. Make sure that execute permissions are set on the self-extracting binary.
    Run this command:
    chmod +x jdk-6u3-linux-amd64.bin

    3. Change directory to the location where you would like the files to be installed.

    The next step installs the JDK into the current directory.

    4. Run the self-extracting binary.

    Execute the downloaded file, prepended by the path to it. For example, if the file is in the current directory, prepend it with "./" (necessary if "." is not in the PATH environment variable):

    ./jdk-6u3-linux-amd64.bin

    The binary code license is displayed, and you are prompted to agree to its terms.

    The JDK files are installed in a directory called jdk1.6.0_03 in the current directory. 


    Installation of RPM File

    1. Download and check the file size.

    You can download to any directory you choose.

    Before you download the file, notice its byte size provided on the download page on the web site. Once the download has completed, compare that file size to the size of the downloaded file to make sure they are equal.

    2. Become root by running the su command and entering the super-user password.

    3. Extract and install the contents of the downloaded file.

    Change directory to where the downloaded file is located and run these commands to first set the executable permissions and then run the binary to extract and run the RPM file:

    chmod a+x jdk-6<version>-linux-i586-rpm.bin

    ./jdk-6<version>-linux-i586-rpm.bin

    Note that the initial "./" is required if you do not have "." in your PATH environment variable.

    The script displays a binary license agreement, which you are asked to agree to before installation can proceed. Once you have agreed to the license, the install script creates and runs the file jdk-6<version>-linux-i586.rpm in the current directory.

    NOTE - If instead you want to only extract the RPM file but not install it, you can run the .bin file with the -x argument. You do not need to be root to do this.

    4. Delete the bin and rpm file if you want to save disk space.

    5. Exit the root shell.
    The RPM packages creates two links /usr/java/latest and /usr/java/default. 

    • The /usr/java/latest link will always point to the version of Java that Sun Microsystems considers the latest version.  Subsequent upgrades of the packages will overwrite this value if it is not the latest version.
    • By default, /usr/java/default points to /usr/java/latest. However, if administrators change /usr/java/default to  point to another version of Java, subsequent package upgrades will be provided by the administrators and cannot be overwritten.
    When the JDK is installed, links to  javac jar and javadoc are also created apart from the JRE links. These links point to the appropriate tool referenced by /usr/java/default. This allows the user to easily run the default version of these Java tools.

    A new service script, named jexec, is added to /etc/init.d. This script allows users to directly execute any standalone JAR file that has an execution permission set. This can be demonstrated using an example from the JDK:
    cd /usr/java/jdk1.6.0/demo/jfc/SwingSet2
    chmod +x SwingSet2.jar
    SwingSet2.jar
    Set environment variable in ubuntu
    modify etc/environment
    add JAVA_HOME="/opt/jdk/bin" This is the path to jdk