這是 Debian-based 的 Linux 特有的 bug...
事情發生在安裝好 sun-java6-jdk, eclipse, ADT 之後,打開 Window -> Android SDK and AVD manager 時,Eclipse 的 Console 視窗會開始一直跳出下面這樣的訊息
[2010-03-04 23:04:42 - ddms]Failed to reopen debug port for Selected Client to: 8700
[2010-03-04 23:04:42 - ddms]不適用的引數
java.net.SocketException: 不適用的引數
at sun.nio.ch.Net.bind(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:119)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:52)
at com.android.ddmlib.MonitorThread.reopenDebugSelectedPort(Unknown Source)
at com.android.ddmlib.MonitorThread.run(Unknown Source)
[2010-03-04 23:04:42 - DeviceMonitor]Connection attempts: 1
[2010-03-04 23:04:43 - DeviceMonitor]Connection attempts: 2
[2010-03-04 23:04:45 - DeviceMonitor]Connection attempts: 3
拜過谷歌大神後,得到解法如下
sudo sysctl -w net.ipv6.bindv6only=0
重開機後也要保持設定值,則修改 /etc/sysctl.d/bindv6only.conf 裡的的設定值為
net.ipv6.bindv6only = 0
2011年10月6日 星期四
2011年3月14日 星期一
星海二-自由之翼遊戲界面缺字問題解法
To add nopat to grub, open a console and edit /etc/default/grub
> sudo nano /etc/default/grub
Change the line:
> GRUB_CMDLINE_LINUX=""
to
> GRUB_CMDLINE_LINUX="nopat"
Save and exit, then run:
> sudo update-grub
再重開機就好了,雖然level不到不知道為何會這樣。
> sudo nano /etc/default/grub
Change the line:
> GRUB_CMDLINE_LINUX=""
to
> GRUB_CMDLINE_LINUX="nopat"
Save and exit, then run:
> sudo update-grub
再重開機就好了,雖然level不到不知道為何會這樣。
2011年3月9日 星期三
youtube to mp3 線上轉換器
http://www.audiothief.com/zh-chs/Video
超方便...
把 youtube 影片網址貼上 按 converter
過20秒就會出現 mp3 連結給你下載了...
超方便...
把 youtube 影片網址貼上 按 converter
過20秒就會出現 mp3 連結給你下載了...
[轉貼] mencoder 和ffmpeg常用命令
mencoder 和ffmpeg常用命令
先从Mencoder这个开始,将所有格式转AVI,
RMVB转AVI
mencoder 1.rmvb -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -o rmvb.avi
RM转AVI
mencoder 1.rm -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -o rm.avi
MPEG转AVI
mencoder mp4.mpeg -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -o mp4.avi
MOV转AVI
mencoder qtime.mov -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -o qtime.avi
WMV转AVI 包括WMV7到WMV9,只实验到WMV9
mencoder m7.wmv -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -o m7.avi
RV转AVI
mencoder 1.rv -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -o rv.avi
等等……格式,参数不变,改文件名就好了。这里参数是什么意思,我目前还不懂,学习中,你可以在网上找找,找到告诉我啊,谢谢。
接下来是FFMPEG上场。
AVI转FLV
ffmpeg -i test.avi -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 test.flv
抓图JPG。
ffmpeg -i 2.wmv -y -f image2 -ss 8 -t 0.001 -s 350x240 test.jpg
3GP转FLV
mencoder -vf scale=320:240 -ffourcc FLV1 -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -ovc lavc -lavcopts vcodec=flv:vbitrate=200 -srate 22050 -oac lavc -lavcopts acodec=mp3:abitrate=56 ok\1.3gp -o ok\3gp.flv
MOV转FLV
mencoder -vf scale=320:240 -ffourcc FLV1 -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -ovc lavc -lavcopts vcodec=flv:vbitrate=200 -srate 22050 -oac lavc -lavcopts acodec=mp3:abitrate=56 ok\qtime.mov -o ok\mov.flv
RMVB转FLV
mencoder -vf scale=320:240 -ffourcc FLV1 -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -ovc lavc -lavcopts vcodec=flv:vbitrate=200 -srate 22050 -oac lavc -lavcopts acodec=mp3:abitrate=56 ok\1.rmvb -o ok\rmvb.flv
WMV转FLV
mencoder -vf scale=320:240 -ffourcc FLV1 -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -ovc lavc -lavcopts vcodec=flv:vbitrate=200 -srate 22050 -oac lavc -lavcopts acodec=mp3:abitrate=56 ok\m9.wmv -o ok\m9.flv
等等等…………
以上的参数通用,只要在输入的ok\m9.wmv换成你自己相应的格式就好,绝对可以,这次测试完全OK,效果点这里,给大家看看,我近期的成果,已实现的。
先从Mencoder这个开始,将所有格式转AVI,
RMVB转AVI
mencoder 1.rmvb -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -o rmvb.avi
RM转AVI
mencoder 1.rm -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -o rm.avi
MPEG转AVI
mencoder mp4.mpeg -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -o mp4.avi
MOV转AVI
mencoder qtime.mov -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -o qtime.avi
WMV转AVI 包括WMV7到WMV9,只实验到WMV9
mencoder m7.wmv -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -o m7.avi
RV转AVI
mencoder 1.rv -oac mp3lame -lameopts preset=64 -ovc xvid -xvidencopts bitrate=600 -of avi -o rv.avi
等等……格式,参数不变,改文件名就好了。这里参数是什么意思,我目前还不懂,学习中,你可以在网上找找,找到告诉我啊,谢谢。
接下来是FFMPEG上场。
AVI转FLV
ffmpeg -i test.avi -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 test.flv
抓图JPG。
ffmpeg -i 2.wmv -y -f image2 -ss 8 -t 0.001 -s 350x240 test.jpg
3GP转FLV
mencoder -vf scale=320:240 -ffourcc FLV1 -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -ovc lavc -lavcopts vcodec=flv:vbitrate=200 -srate 22050 -oac lavc -lavcopts acodec=mp3:abitrate=56 ok\1.3gp -o ok\3gp.flv
MOV转FLV
mencoder -vf scale=320:240 -ffourcc FLV1 -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -ovc lavc -lavcopts vcodec=flv:vbitrate=200 -srate 22050 -oac lavc -lavcopts acodec=mp3:abitrate=56 ok\qtime.mov -o ok\mov.flv
RMVB转FLV
mencoder -vf scale=320:240 -ffourcc FLV1 -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -ovc lavc -lavcopts vcodec=flv:vbitrate=200 -srate 22050 -oac lavc -lavcopts acodec=mp3:abitrate=56 ok\1.rmvb -o ok\rmvb.flv
WMV转FLV
mencoder -vf scale=320:240 -ffourcc FLV1 -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -ovc lavc -lavcopts vcodec=flv:vbitrate=200 -srate 22050 -oac lavc -lavcopts acodec=mp3:abitrate=56 ok\m9.wmv -o ok\m9.flv
等等等…………
以上的参数通用,只要在输入的ok\m9.wmv换成你自己相应的格式就好,绝对可以,这次测试完全OK,效果点这里,给大家看看,我近期的成果,已实现的。
2010年8月11日 星期三
由 source 安裝特定版本 wine
需先安裝 git - 和svn類似的版本管理工具
#aptitude install git-core
取得wine原始碼
$git clone git://source.winehq.org/git/wine.git ~/git-workspace/wine
$cd ~/git-workspace/wine
切換到想要的 wine branch
$git checkout wine-1.2
編譯 wine
$./configure && make depend && make
安裝 wine
#make install
反安裝 wine
#make uninstall
#aptitude install git-core
取得wine原始碼
$git clone git://source.winehq.org/git/wine.git ~/git-workspace/wine
$cd ~/git-workspace/wine
切換到想要的 wine branch
$git checkout wine-1.2
編譯 wine
$./configure && make depend && make
安裝 wine
#make install
反安裝 wine
#make uninstall
wine 的方便擴充工具 winetricks
安裝好 wine 後,有時仍然不敷使用,如:directx9 , ie6 ...等等 lib 並不容易安裝與設定
只要下載 winetricks 這個工具就可以很容易的安裝各式 windows 工具軟體
下載頁與教學:
http://wiki.winehq.org/winetricks
範例: $sh winetricks d3dx9 ie6
只要下載 winetricks 這個工具就可以很容易的安裝各式 windows 工具軟體
下載頁與教學:
http://wiki.winehq.org/winetricks
範例: $sh winetricks d3dx9 ie6
2010年6月7日 星期一
dvd player gxine
在 debian 上用 mplayer 可以看大多數的影片檔了
可是遇到 dvd 光碟時 常常需要許多的設定
gxine 則比較方便 一安裝好就可以正常播放 dvd 光碟影片
無論是字幕或是選擇語言章節都很順利
可是遇到 dvd 光碟時 常常需要許多的設定
gxine 則比較方便 一安裝好就可以正常播放 dvd 光碟影片
無論是字幕或是選擇語言章節都很順利
2010年1月29日 星期五
maven 查詢點紀錄
Spring EBR:
http://www.springsource.com/repository/app/
maven repository:
http://mvnrepository.com/
maven browser:
http://www.mvnbrowser.com/index.html
http://www.springsource.com/repository/app/
maven repository:
http://mvnrepository.com/
maven browser:
http://www.mvnbrowser.com/index.html
java System.getProperty() 參數紀錄
java.version – Java Runtime Environment version
java.vendor – Java Runtime Environment vendor
java.vendor.url – Java vendor URL
java.home – Java installation directory
java.vm.specification.version – Java Virtual Machine specification version
java.vm.specification.vendor – Java Virtual Machine specification vendor
java.vm.specification.name – Java Virtual Machine specification name
java.vm.version – Java Virtual Machine implementation version
java.vm.vendor – Java Virtual Machine implementation vendor
java.vm.name – Java Virtual Machine implementation name
java.specification.version – Java Runtime Environment specification version
java.specification.vendor – Java Runtime Environment specification vendor
java.specification.name – Java Runtime Environment specification name
java.class.version - Java class format version number
java.class.path – Java class path
java.library.path – List of paths to search when loading libraries
java.io.tmpdir – Default temp file path
java.compiler – Name of JIT compiler to use
java.ext.dirs – Path of extension directory or directories
os.name – Operating system name
os.arch – Operating system architecture
os.version – Operating system version
file.separator – File separator ("/" on UNIX)
path.separator – Path separator (":" on UNIX)
line.separator – Line separator ("\n" on UNIX)
user.name – User's account name
user.home – User's home directory
user.dir – User's current working directory
java.vendor – Java Runtime Environment vendor
java.vendor.url – Java vendor URL
java.home – Java installation directory
java.vm.specification.version – Java Virtual Machine specification version
java.vm.specification.vendor – Java Virtual Machine specification vendor
java.vm.specification.name – Java Virtual Machine specification name
java.vm.version – Java Virtual Machine implementation version
java.vm.vendor – Java Virtual Machine implementation vendor
java.vm.name – Java Virtual Machine implementation name
java.specification.version – Java Runtime Environment specification version
java.specification.vendor – Java Runtime Environment specification vendor
java.specification.name – Java Runtime Environment specification name
java.class.version - Java class format version number
java.class.path – Java class path
java.library.path – List of paths to search when loading libraries
java.io.tmpdir – Default temp file path
java.compiler – Name of JIT compiler to use
java.ext.dirs – Path of extension directory or directories
os.name – Operating system name
os.arch – Operating system architecture
os.version – Operating system version
file.separator – File separator ("/" on UNIX)
path.separator – Path separator (":" on UNIX)
line.separator – Line separator ("\n" on UNIX)
user.name – User's account name
user.home – User's home directory
user.dir – User's current working directory
2010年1月15日 星期五
cx_freeze 將 python 程式轉換成 exe
安裝 cx_freeze 前需先安裝好 python
再根據安裝的 python 版本下載對應的 cx_freeze 安裝程式
下載網站
http://cx-freeze.sourceforge.net/
安裝完成後會在原本的 python 安裝目錄下的 Scripts 目錄出現 cxfreeze cxfreeze.bat 兩個檔案
將要轉換的 python 程式 及 圖示檔 copy 到 Scripts 目錄下,並開啟 dos command line , cd 到 Scripts 下
執行:
C:\Python26\Scripts\>cxfreeze --base-name=Win32GUI --icon=app.ico app.py
--base-name=Win32GUI 是用來使用在執行 gui 程式時不必顯示 console 視窗,和將 副檔名 改為 app.pyw 意思一樣。
--icon 就是用來指定 產生的執行檔 的 icon 圖檔。
完成後,會在 Scripts 下建立 dist 資料夾,並產生幾個檔案,當然也包含 app.exe
dist 下的所有檔案都要有才能執行 app.exe (正常執行)
再根據安裝的 python 版本下載對應的 cx_freeze 安裝程式
下載網站
http://cx-freeze.sourceforge.net/
安裝完成後會在原本的 python 安裝目錄下的 Scripts 目錄出現 cxfreeze cxfreeze.bat 兩個檔案
將要轉換的 python 程式 及 圖示檔 copy 到 Scripts 目錄下,並開啟 dos command line , cd 到 Scripts 下
執行:
C:\Python26\Scripts\>cxfreeze --base-name=Win32GUI --icon=app.ico app.py
--base-name=Win32GUI 是用來使用在執行 gui 程式時不必顯示 console 視窗,和將 副檔名 改為 app.pyw 意思一樣。
--icon 就是用來指定 產生的執行檔 的 icon 圖檔。
完成後,會在 Scripts 下建立 dist 資料夾,並產生幾個檔案,當然也包含 app.exe
dist 下的所有檔案都要有才能執行 app.exe (正常執行)
2009年12月31日 星期四
ivy 指定設定檔位置
ivy 是一個和 ant 配合得很好的 lib 管理工具,簡單安裝及設定後,只要在 ant 的 build.xml 裡加上一個 "resolve" target
target 裡使用 ivy 提供的 <ivy:retrieve> ant task 並配合 ivy.xml 條列出所需 lib 的組織、名稱、版本
就可以由 maven repository 取得專案所需的 lib
但是 ivy 初始預設的設定往往不足以應付專案所需,例如需要對 ivy 另加不同的 repository 站點等等…
這些特殊設定必需由 ivysettings.xml 設定檔來完成,在預設的情型下,只要在 build.xml 同目錄下
加入檔名為 ivysettings.xml 的設定檔,ivy 就會使用這個設定檔覆蓋掉 ivy.jar 裡預設提供的 ivysettings.xml
但如果要將 ivysettings.xml 改名或移到別的目錄,就必須增加 <ivy:settings> task 如以下列範例:
<!-- resolve -->
<target name="resolve">
<ivy:settings id="my-ivysettings" file="ivy/myivysettings.xml" />
<ivy:retrieve settingsref="my-ivysettings" />
</target>
target 裡使用 ivy 提供的 <ivy:retrieve> ant task 並配合 ivy.xml 條列出所需 lib 的組織、名稱、版本
就可以由 maven repository 取得專案所需的 lib
但是 ivy 初始預設的設定往往不足以應付專案所需,例如需要對 ivy 另加不同的 repository 站點等等…
這些特殊設定必需由 ivysettings.xml 設定檔來完成,在預設的情型下,只要在 build.xml 同目錄下
加入檔名為 ivysettings.xml 的設定檔,ivy 就會使用這個設定檔覆蓋掉 ivy.jar 裡預設提供的 ivysettings.xml
但如果要將 ivysettings.xml 改名或移到別的目錄,就必須增加 <ivy:settings> task 如以下列範例:
<!-- resolve -->
<target name="resolve">
<ivy:settings id="my-ivysettings" file="ivy/myivysettings.xml" />
<ivy:retrieve settingsref="my-ivysettings" />
</target>
2009年12月29日 星期二
透過 ant 和 vbscript 合作建立 windows 捷徑檔
先以 vbscript 寫一段建立捷徑的程式
// 讀取參數
Set args = WScript.Arguments
installedFolder = args.Item(0)
// 取得 windows shell 物件
Set objShell = WScript.CreateObject("WScript.Shell")
// 取得 windows fs 物件
Set objFso = WScript.CreateObject("Scripting.FileSystemObject")
// 桌面路徑
strDesktopFolder = objShell.SpecialFolders("Desktop")
// 程式集路徑
strProgramsFolder = objShell.SpecialFolders("Programs")
// 建立資料夾(程式集裡)
objFso.CreateFolder(strProgramsFolder & "\app provider")
// 建立捷徑物件
Set objDesktopShortCut = objShell.CreateShortcut(strDesktopFolder & "\feeler.lnk")
// 設定目標
objDesktopShortCut.TargetPath = chr(34) & installedFolder & "\app.exe" & chr(34)
// 設定圖示
objDesktopShortCut.IconLocation = installedFolder & "\resources\images\app.ico, 0"
// 設定執行工作目錄
objDesktopShortCut.WorkingDirectory = installedFolder & "\"
// 儲存桌面捷徑
objDesktopShortCut.Save
// 依同法再建立程式集捷徑
...
完成 vbscript 後以 ant 的 exec task 執行 (vbscript 程式可透過 cscript 命令執行)
<target name="config">
<exec dir="${install.path.dir}" executable="cscript" os="Windows XP" output="shortcut.log">
<arg value="resources/shortcut.vbs" />
<arg value="${install.path.dir}" />
</exec>
</target>
// 讀取參數
Set args = WScript.Arguments
installedFolder = args.Item(0)
// 取得 windows shell 物件
Set objShell = WScript.CreateObject("WScript.Shell")
// 取得 windows fs 物件
Set objFso = WScript.CreateObject("Scripting.FileSystemObject")
// 桌面路徑
strDesktopFolder = objShell.SpecialFolders("Desktop")
// 程式集路徑
strProgramsFolder = objShell.SpecialFolders("Programs")
// 建立資料夾(程式集裡)
objFso.CreateFolder(strProgramsFolder & "\app provider")
// 建立捷徑物件
Set objDesktopShortCut = objShell.CreateShortcut(strDesktopFolder & "\feeler.lnk")
// 設定目標
objDesktopShortCut.TargetPath = chr(34) & installedFolder & "\app.exe" & chr(34)
// 設定圖示
objDesktopShortCut.IconLocation = installedFolder & "\resources\images\app.ico, 0"
// 設定執行工作目錄
objDesktopShortCut.WorkingDirectory = installedFolder & "\"
// 儲存桌面捷徑
objDesktopShortCut.Save
// 依同法再建立程式集捷徑
...
完成 vbscript 後以 ant 的 exec task 執行 (vbscript 程式可透過 cscript 命令執行)
<target name="config">
<exec dir="${install.path.dir}" executable="cscript" os="Windows XP" output="shortcut.log">
<arg value="resources/shortcut.vbs" />
<arg value="${install.path.dir}" />
</exec>
</target>
2009年12月28日 星期一
pythonw.exe
Windows 版本的 python 安裝後除了有 python.exe 直譯器之外,還有多一個 pythonw.exe
一般的 python 主程式如果副檔名為 *.py 則會預設以 python.exe 執行,執行時會先彈出一個 dos command line
以方便進行 輸入/輸出 ,但是一般的 GUI 程式是不需要用 command line 做 輸入/輸出 的,這樣一來
這一個 dos command line 就顯得多餘了,可以簡單的透過將 python 主程式的 副檔名 改為 *.pyw
這樣執行時 就會以 pythonw.exe 來執行 python 程式 ,也就不會彈出 dos command line
一般的 python 主程式如果副檔名為 *.py 則會預設以 python.exe 執行,執行時會先彈出一個 dos command line
以方便進行 輸入/輸出 ,但是一般的 GUI 程式是不需要用 command line 做 輸入/輸出 的,這樣一來
這一個 dos command line 就顯得多餘了,可以簡單的透過將 python 主程式的 副檔名 改為 *.pyw
這樣執行時 就會以 pythonw.exe 來執行 python 程式 ,也就不會彈出 dos command line
2009年12月22日 星期二
lenny + apache2 + mod_jk + tomcat55 設置
先安裝好需要的套件:
sudo aptitude install apache2 libapache2-mod-jk tomcat5.5 tomcat5.5-admin tomcat5.5-webapps
設定 tomcat:
sudo vim /etc/default/tomcat5.5
JAVA_HOME=/usr/lib/jvm/java-6-sun
TOMCAT5_SECURITY=no
若 TOMCAT5_SECURITY=yes
則會啟用 java 的 security manager 並以 /etc/tomcat5.5/catalina.policy 下的規則為依據
避免複雜設定先設定為 no 待有安全問題再進行詳細設定
tomcat webapps 位於 /var/lib/tomcat5.5/webapps/ 將 war 檔放到此目錄下過一會會自動解壓縮
先連線到 http://localhost:8180/webapp/ 看看是否可以正常連線
設定 apache jk module
在 /etc/apache2/mod-available/ 目錄下建立 jk.conf 檔案 內容如下:
JkWorkersFile /etc/apache2/workers.properties
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel info
JkMount /webapp/* worker1
這檔案是設定 jk 以 /etc/apache2/workers.properties 的設定建立 worker (可以多個)
接著建立 /etc/apache2/workers.properties 內容如下:
# Defining a worker named worker1 and of type ajp13
worker.list=worker1
# Set properties for worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
這檔案是建立一個 名稱為 worker1 且 type為 ajp13 的 worker
完成之後就可以 enable jk module
sudo a2enmod jk
完成後可以到 /etc/apache2/mod-enable/ 檢查看看有沒有兩個連結
$ ls -la | grep jk
lrwxrwxrwx 1 root root 25 2009-12-22 16:41 jk.conf -> ../mods-available/jk.conf
lrwxrwxrwx 1 root root 25 2009-12-22 16:41 jk.load -> ../mods-available/jk.load
接著要設定 /etc/apache2/sites-available/default 檔案
vim /etc/apache2/sites-available/default
加入:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
JkMount /webapp/* worker1
…
</VirtualHost>
最後再重新啟動 apache
sudo /etc/init.d/apache2 restart
這次改以 80 port 連接 webapp
http://localhost/webapp/
順利的話就可以看到和用 8180 port 連接的相同結果
sudo aptitude install apache2 libapache2-mod-jk tomcat5.5 tomcat5.5-admin tomcat5.5-webapps
設定 tomcat:
sudo vim /etc/default/tomcat5.5
JAVA_HOME=/usr/lib/jvm/java-6-sun
TOMCAT5_SECURITY=no
若 TOMCAT5_SECURITY=yes
則會啟用 java 的 security manager 並以 /etc/tomcat5.5/catalina.policy 下的規則為依據
避免複雜設定先設定為 no 待有安全問題再進行詳細設定
tomcat webapps 位於 /var/lib/tomcat5.5/webapps/ 將 war 檔放到此目錄下過一會會自動解壓縮
先連線到 http://localhost:8180/webapp/ 看看是否可以正常連線
設定 apache jk module
在 /etc/apache2/mod-available/ 目錄下建立 jk.conf 檔案 內容如下:
JkWorkersFile /etc/apache2/workers.properties
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel info
JkMount /webapp/* worker1
這檔案是設定 jk 以 /etc/apache2/workers.properties 的設定建立 worker (可以多個)
接著建立 /etc/apache2/workers.properties 內容如下:
# Defining a worker named worker1 and of type ajp13
worker.list=worker1
# Set properties for worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
這檔案是建立一個 名稱為 worker1 且 type為 ajp13 的 worker
完成之後就可以 enable jk module
sudo a2enmod jk
完成後可以到 /etc/apache2/mod-enable/ 檢查看看有沒有兩個連結
$ ls -la | grep jk
lrwxrwxrwx 1 root root 25 2009-12-22 16:41 jk.conf -> ../mods-available/jk.conf
lrwxrwxrwx 1 root root 25 2009-12-22 16:41 jk.load -> ../mods-available/jk.load
接著要設定 /etc/apache2/sites-available/default 檔案
vim /etc/apache2/sites-available/default
加入:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
JkMount /webapp/* worker1
…
</VirtualHost>
最後再重新啟動 apache
sudo /etc/init.d/apache2 restart
這次改以 80 port 連接 webapp
http://localhost/webapp/
順利的話就可以看到和用 8180 port 連接的相同結果
swing Window 元件置頂
無論是 JFrame、JDialog 均可使用下列 method 將 window 置於最上層,
即使切換視窗也不會被 focus 的視窗所蓋到。
public final void setAlwaysOnTop(boolean alwaysOnTop)
2009年12月20日 星期日
debian 下格式化隨身碟為 vfat
必須使用 mkfs.vfat 來進行格式化
而 mkfs.vfat 預設沒有安裝,查詢他所存在的 deb 套件位置
$ apt-file search mkfs.vfat
dosfstools: sbin/mkfs.vfat
可以發現存在於 dosfstools 下
先安裝 dosfstools 再格式化隨身碟為 vfat:
sudo aptitude install dosfstools
sudo mkfs.vfat /dev/sdb1
而 mkfs.vfat 預設沒有安裝,查詢他所存在的 deb 套件位置
$ apt-file search mkfs.vfat
dosfstools: sbin/mkfs.vfat
可以發現存在於 dosfstools 下
先安裝 dosfstools 再格式化隨身碟為 vfat:
sudo aptitude install dosfstools
sudo mkfs.vfat /dev/sdb1
2009年12月18日 星期五
自定以圖片為背景的 JPanel
繼承 JPanel 並 override paintComponent(Graphics gc) 就可以了:
public class ImageBackgroundJPanel extends JPanel {
private Image backgroundImg = null;
public ImageBackgroundJPanel(String imagePath) {
backgroundImg = new ImageIcon(imagePath).getImage();
}
@Override
protected void paintComponent(Graphics gc) {
gc.drawImage(backgroundImg, 0, 0, this);
}
}
使用 jgoodies 的 look and feel
jgoodies 有許多產品,下載最新版的 jgoodies libraries looks 就可以了,
目前使用 2.2.2 版,將 looks-2.2.2.jar 加到 classpath 下
在執行到 swing 的任何程式之前,先加入以下 code 設定 L&F (look and feel)
// 設定銀色主題,有多種可用,必須在設定 L&F 前設定
// com.jgoodies.looks.plastic.theme - 主題的 package
PlasticLookAndFeel.setPlasticTheme(new Silver());
// 設定 look and feel ,在 linux 下使用 Plastic 系列比較沒問題,三種可用
//com.jgoodies.looks.plastic.PlasticLookAndFeel//com.jgoodies.looks.plastic.Plastic3DLookAndFeel
//com.jgoodies.looks.plastic.PlasticXPLookAndFeel
UIManager.setLookAndFeel(new PlasticXPLookAndFeel());
python 取得 os 的 path 分隔符號
使用 os moudle 取得有關 os 的資訊
import os
javaLibraryPath = "." + os.pathsep + "bundle" + os.pathsep + "lib"
windows 下 javaLibraryPath = .;bundle;lib
linux 下 javaLibraryPath = .:bundle:lib
help(os) 片斷說明如下
- all functions from posix, nt, os2, mac, or ce, e.g. unlink, stat, etc.
- os.path is one of the modules posixpath, ntpath, or macpath
- os.name is 'posix', 'nt', 'os2', 'mac', 'ce' or 'riscos'
- os.curdir is a string representing the current directory ('.' or ':')
- os.pardir is a string representing the parent directory ('..' or '::')
- os.sep is the (or a most common) pathname separator ('/' or ':' or '\\')
- os.extsep is the extension separator ('.' or '/')
- os.altsep is the alternate pathname separator (None or '/')
- os.pathsep is the component separator used in $PATH etc
- os.linesep is the line separator in text files ('\r' or '\n' or '\r\n')
- os.defpath is the default search path for executables
- os.devnull is the file path of the null device ('/dev/null', etc.)
訂閱:
文章 (Atom)