2010年5月22日 星期六

如何在jade的環境下動態載入Agent並執行之

對於沒學過java,而直接寫jade的人,一定對這個標題有問題

有問題的原因就是:jade沒有提供function來做

可是在找過網路後,發現有 java.lang.ClassLoaderjava.net.URLClassLoader 可以用。

使用方式如下:

try{
            URL url[] = new URL[1];
            url[0] = new URL("file:///pathTojar.jar");
            ClassLoader m_loader = new ClassLoader(url, ClassLoader.getSystemClassLoader());
            getContainerController().acceptNewAgent("test", (Agent)m_loader.loadClass("examples.hello.HelloWorldAgent").newInstance());
            getContainerController().getAgent("test").start();
        } catch(Exception e) {
            e.printStackTrace();
}

如此一來,就可以將jar檔裡的class檔讀出來,並動態執行之

2010年5月11日 星期二

WallpaperTray is not working in Ubuntu 10.04 (Lucid)

WallpaperTray is a good Gnome applet that it altomatically search user defined directory and ramdomly change your Wallpaper.  But it seems that it do not have anyone to maintaince the project.  And in Ubuntu 10.04, it is not the default packet that you can select from the Synaptic.  But you can install by compiling the orginal code.  Here is how it works.

1), download the wallpaper-tray_0.5.5.orig.tar.gz from Here.

2), extract it to a folder.  For example, /home//wp_tray

3), open the command, change the folder to where it is extracted.
cd ~/wp_tray

4), type the following command
./configure  --prefix=/usr
Normally, it  will have some error.  That is because you have some packet that is not installed. (For example, the gnome-dev.)  The packet you lack of will show at the bottom of the console window, just scroll up a little, and you will see the list.  Open Synaptic and install all packet you need.  Until there is no error when you excute this command.

5), compile the source code by entering the following command
make
This will compile all the source code.  It may takes a while.

6), install WallpaperTray by the following command
sudo make install
This will copy all the binary file that just compiled to the proper location in your OS.

7), logout and login to refresh the gnome setting.  After that, you may select WallpaperTray as the old way.

Also note that there should have no error when excuting the commands upon.

You may also notice that there is the .deb file of WallpaperTray in here when you download the source code on step 1.  Why not just download the .deb file from one of the list?  The reason is simple.  Some of the packet it depands have updated, but the WallpaperTray project did not update.  When installing, it will say that you have no ... package installed, but the packet is the old packet.  And this is the reason that you can not install this applet directly from Synaptic.  However, we can't install from the .deb file, but we can re-compile the source code and link to the newer library, and the problem is solved.

Updating Ubuntu from 9.04(Jaunty) to 10.04(Lucid) with clean install (not update)

Since Ubuntu 9.10(karmic) have some issue with my external hard disk.  I stopped and wait until 10.04 release.  Here is how I update from 9.04 to 10.04 using clean install.

1), change the /home from ext3 to ext4.

2), format the root(/) to fat32 (using GParted in the Ubuntu Desktop version).

3), format the root(/) to ext4 (using GParted in the Ubuntu Desktop version).

4), install Ubuntu 10.04.

5), when install, choose where the root is install, and also set your /home partition as /home. (It will not format the /home, just for mount issue when startup.)

Note that on the step 2 and 3, it seems that it could directly format to ext4, or when install 10.04, it will format directly.  But as I tested on other disk, It did not success, and it shows that it cannot remove another operating system (that is, 9.04).  So I format the root to fat32, and than format back.  Another reason is that if you delete the partition and create a new partition, the partitioning table on the harddrive may not work as what you expected.  It may change from sda5 to sda9 (in my case).

2010年5月8日 星期六

Ubuntu flash 亂碼的問題

每次重灌都遇到同樣的問題,就把他收到blog中啦

做法如下:

在 command line 下輸入
sudo gedit /etc/fonts/conf.d/49-sansserif.conf

然後將兩個「sans-serif」改成「sans serif」即可


參考網站:http://blog.yam.com/lijohnson/trackback/18793178