2012年3月15日 星期四

Linux環境tomcat的setclasspath.sh檔

Tomcat在bin底下有一支setclasspath.sh可以設定tomcat所要使用的JDK與JRE。
用法範例:

JAVA_HOME=/usr/java/jdk/jdk1.6.0
JRE_HOME=/usr/java/jre/jre1.6.0

PATH=$JAVA_HOME/bin:$PATH

CLASSPATH=.:JAVA_HOME/lib

當你想讓tomcat不想使用環境預設的JDK時會用的到。

2012年3月8日 星期四

apt主機設定檔 ect/apt/source.list

//編輯 source.list
#sudo vi /etc/apt/source.list

//內容
# deb cdrom:[Ubuntu 11.10 _Oneiric Ocelot_ - Release amd64 (20111012)]/ dists/oneiric/main/binary-i386/

# deb cdrom:[Ubuntu 11.10 _Oneiric Ocelot_ - Release amd64 (20111012)]/ oneiric main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://archive.ubuntu.com/ubuntu oneiric main restricted
deb-src http://archive.ubuntu.com/ubuntu oneiric main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://archive.ubuntu.com/ubuntu oneiric-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu oneiric-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu oneiric universe
deb-src http://archive.ubuntu.com/ubuntu oneiric universe
deb http://archive.ubuntu.com/ubuntu oneiric-updates universe
deb-src http://archive.ubuntu.com/ubuntu oneiric-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://archive.ubuntu.com/ubuntu oneiric multiverse
deb-src http://archive.ubuntu.com/ubuntu oneiric multiverse
deb http://archive.ubuntu.com/ubuntu oneiric-updates multiverse
deb-src http://archive.ubuntu.com/ubuntu oneiric-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu oneiric-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu oneiric-backports main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu oneiric-security main restricted
deb-src http://archive.ubuntu.com/ubuntu oneiric-security main restricted
deb http://archive.ubuntu.com/ubuntu oneiric-security universe
deb-src http://archive.ubuntu.com/ubuntu oneiric-security universe
deb http://archive.ubuntu.com/ubuntu oneiric-security multiverse
deb-src http://archive.ubuntu.com/ubuntu oneiric-security multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
deb http://archive.canonical.com/ubuntu oneiric partner
deb-src http://archive.canonical.com/ubuntu oneiric partner

## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
deb http://extras.ubuntu.com/ubuntu oneiric main
deb-src http://extras.ubuntu.com/ubuntu oneiric main
deb http://archive.canonical.com/ubuntu lucid partner
deb-src http://archive.canonical.com/ubuntu lucid partner

2012年3月7日 星期三

ubuntu Server 安裝 x-windows

Step1.請先參考ubuntu server apt proxy 設定
Setp2.x-windows install

  • 台灣下載目前有點問題,請參考 http://jt-java.blogspot.com/,將server位置中有tw的都拿掉。
  • 將被註解的#位址都打開
  • apt-get update 
  • apt-get upgrade 
  • sudo aptitude install x-window-system-core
  • sudo aptitude install xorg
  • sudo aptitude install ubuntu-desktop
    or
    sudo aptitude install xubuntu-desktop
    or
    sudo aptitude install fluxbox fluxconf

  • sudo aptitude install gdm
    or
    sudo aptitude install xdm    
  • sudo reboot






相關參考連結:




有關apt使用參考:
http://apt.nc.hcc.edu.tw/web/apt/apt.html
http://www.debian.org/doc/manuals/apt-howto/ch-apt-get.zh-tw.html

Ubuntu Server apt proxy設定

Step1.
  #sudo vi /etc/apt/apt.conf


//若vi不能顯示中文時,將其環境先改成英文顯示

  #LANG=en_US 



Step2.
vi中按下i進入編輯模式,輸入:


Acquire::http::proxy "http://[proxy address]:[prot number]";
Acquire::https::proxy "https://[proxy address]:[prot number]";
Acquire::ftp::proxy "ftp://[proxy address]:[prot number]";


 vi中按下Esc回到一般模式,打入:w!儲存檔案


如此apt指令才能更新




參考:
鳥哥http://linux.vbird.org/linux_server/0450apt.php



2012年3月3日 星期六

Ubuntu安裝桌面捷徑工具

Ubuntu11.10拿掉了原本的的右鍵建立捷徑,可參考下列方式使用


安裝
sudo apt-get install --no-install-recommends gnome-panel


使用方法
gnome-desktop-item-edit ~/Desktop/ --create-new


ubuntu 新增啟動圖示

OS Ubuntu 10.04


Step1.新增啟動圖示
  • 滑鼠右鍵→新增啟動圖示
Step2.欄位輸入數值 (這裡使用Eclipse作為範例)

  • 類型:應用程式
  • 名稱:eclipse
  • 指令:/opt/eclipse/eclipse











若你想改變ICON點擊圖片即可,然後選擇你想要用的ICON檔案。
eclipse可以使用eclipse資料夾裡的icon.xpm。

Ubuntu 安裝 MySQL的JDBC


※apt安裝方式會自動把環境改成openJDK


Step1.先升級套件
  • sudo apt-get update
Step2.安裝MySQL JDBC
  • sudo apt-get install libmysql-java
Step3.設定環境變數

你可以設定在全體環境的/etc/profile或是個別使用者的/home/[user]/.bashrc。
  • sudo gedit /etc/profile
加入以下文字:
#MySQL JDBC environment
export CLASSPATH=$CLASSPATH:/usr/share/java/mysql.jar

Step4.載入新的環境變數設定

  • source /etc/profile
Step5.看看現在的CLASSPATH
  • echo $CLASSPATH
Step6.寫一個JAVA程式測試看看JDBC
package com.jt;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class DBDemo
{

private static final String driver = "com.mysql.jdbc.Driver";
private static final String url = "jdbc:mysql://127.0.0.1";
private static final String username = "yourDB_username";
private static final String password = "yourDB_password";

/**
* @param args
*/
public static void main(String[] args) throws ClassNotFoundException,SQLException
{
      Connection conn;
      Class.forName(driver);
      conn = DriverManager.getConnection(url, username, password);
      System.out.println("Success");
      conn.close();
}
}

記得在eclipse中要把JDBC的jar給加進來
  • Select Project Properties > Java Build Path
  • Select Libries tab
  • Click Add External Jars
  • Choose the jar file, /usr/share/java/mysql.jar














加進來後可以看到:













參考資料:
安裝說明: