顯示具有 Java 標籤的文章。 顯示所有文章
顯示具有 Java 標籤的文章。 顯示所有文章

Resolve "PHP not found" of PHP/Java Bridge on Gentoo Linux

Environment:
  • Gentoo Linux
  • dev-lang/php-5.3.8 +cgi
  • www-apache/mod_fastcgi-2.4.7_pre0910052141
  • www-servers/tomcat-6.0.32-r1

PHP/Java Bridge: 6.2.1, installed in /var/lib/tomcat-6/webapps/JavaBridge

Problem Description:
Follow the installation guide on the PHP/Java Bridge website.  The test by the following command does not report any error.
java -classpath JavaBridge.war TestInstallation
However, when visiting the URL http://localhost:8080/JavaBridge, an error message is returned:
java.io.IOException: PHP not found. Please install php-cgi.
PHP test command was: [/usr/bin/php-cgi, -v]

Resolution:
  1. Edit /var/lib/tomcat-6/webapps/JavaBridge/WEB-INF/web.xml.  Uncomment the following line:
    <context-param><param-name>php_exec</param-name><param-value>php-cgi</param-value></context-param>
  2. Rename the pre-compiled php-cgi brought by JavaBridge.war.
    $ cd /var/lib/tomcat-6/webapps/JavaBridge/WEB_INF/cgi/i386-linux
    $ mv php.cgi php.cgi.pjb
  3. Create a symbolic link to /usr/bin/php-cgi. Assume the working directory is /var/lib/tomcat-6/webapps/JavaBridge/WEB_INF/cgi/i386-linux.
    $ ln -s /usr/bin/php-cgi .

It is also working to use the pre-compiled php-cgi from PHP/Java Bridge. Instead of steps 2 and 3, simply make the php-cgi executable.
$ chmod +x /var/lib/tomcat-6/webapps/JavaBridge/WEB_INF/cgi/i386-linux/php-cgi
Note that the pre-compiled php-cgi from PHP/Java Bridge is not recommended.

Release of JCBR 0.8.1

Please find this version in the earlier post JCBR: Java Chinese Book Reader. In this version, the following changes are made.
  • Fix a bug in the preference dialog that does not display the gestures correctly.
  • Fix a bug in determining the change of background color and foreground color.

Release of JCBR 0.8.0

Please find this version in the earlier post JCBR: Java Chinese Book Reader. In this version, the following changes are made.
  • Add support of Windows and Linux.
  • Display the selected book name at the bottom of the bookshelves dialog.
  • Make the font of the bookshelves dialog and the TOC dialog customizable.
  • Allow language switching on Windows and Linux.

Release of JCBR 0.7.0

Please find this version in the earlier post JCBR: Java Chinese Book Reader. In this version, the following changes are made.
  • Add gestures.

JCBR: Java Chinese Book Reader


Name: JCBR (Java Chinese Book Reader)
Latest Version: 0.8.0
Platform: Mac OS X, Windows (since 0.8.0), Linux (since 0.8.0)
Supported Files: PDB, uPDB
Note: This application is specially for eBooks made by mPDB.
Previous Versions: 0.60.6.10.7.00.8.0 Mac0.8.0 Windows/Linux

JCBR 是最近寫的一個中文直式閱讀軟體,目前作業系統僅支援 Mac OS X ,而檔案格式僅支援由 mPDB 所製作的 PDB/uPDB 檔案。為什麼要寫這個軟體呢?由於本人一直很喜歡看武俠小說,前不久正好發現 iPhone 上的一個免費電子書軟體:cBook Lite ,透過這個軟體又發現了好讀網站。好讀網站上除了電子書以外,還有好用的中文電子書製作軟體 mPDB 與直式閱讀軟體。這些閱讀軟體有 Windows 版、WinCE 版、Palm 版、SONY CLIE 版、網頁版、iPhone 版與 Andriod 版,雖然有這麼多平台的閱讀軟體,但其中就是少了 Mac OS 。這對上個星期狠心買下 MacBook Pro 的我來說便造成一點困擾。於是花了點時間來為 Mac 寫一個對我來說還算堪用的直式閱讀軟體。

JFileChooser Hangs on Windows XP

之前在寫 GOAL 的時候,幾乎每次開啟檔案或是儲存檔案的時候,只要有選擇檔案的視窗出現, GOAL 就會當掉。經過了幾次實驗之後,終於發現問題所在。這一個問題發生的條件蠻多的,當以下所有條件都成立的話,就很容易讓整個程式當掉。
  1. 作業系統為 Window XP 。
  2. 只使用一個 JFileChooser 來開啟檔案選擇視窗。
  3. 使用 CrossPlatformLookAndFeel 的 look-and-feel 。
  4. 至少有一個 FileFilter 用在 JFileChooser 裡面。
  5. 這個 FileFilter 會有條件地接受某些檔案。
  6. 預設 JFileChooser 所開啟的目錄底下有該 FileFilter 所接受的檔案。
  7. 在 showOpenDialog() 之後呼叫了 resetChoosableFileFilters()。
其實這個問題很早就發現了,只是前幾天才實際去測試發生的條件,也有回報給 Sun 並且被接受為 Bug 6857569

要避免這個問題也蠻簡單的,只要讓其中一個條件不成立就可以了。例如:
  1. 使用 Linux 。
  2. 每次都用新的 JFileChooser 來開啟檔案選擇視窗。
  3. 使用系統預設的 look-and-feel 。
  4. 不要在目錄底下擺 FileFilter 會接受的檔案。
  5. showOpenDialog() 移到 resetChoosableFileFilters() 之前。
作為一個使用者,大概只有 1 跟 4 這兩個作法可以選擇。還好我是 GOAL 的 programmer ,可以直接套用上面的第五個方法。雖然改了之後真的沒有再讓程式當掉,但卻也不保證檔案選擇視窗開了成千上萬次之後會不會發生,畢竟每次用都不會開超過 10 次吧。