Wednesday, January 24, 2007

加载jar文件里的本地库

java程序开发中经常用到JNI调用本地library, 同时又希望将library同class文件编译成一个jar文件以方便deploy.

但是JDK的classloader不支持从jar文件中加载library, 一个变通的方法就是jar里的library以临时文件的方式写到临时目录或java.library目录.

附上两篇文档链接 :

Load Library inside a jar file

使用JNI时,装载本地库的小技巧

Wednesday, January 17, 2007

[Eclipse]Eclipse update support

Those days my work is focus on eclipse's update. Now I understand the general mechanism and meet some issues when using it in development work.

The update mechanism includes four major types: install, enable, disable and uninstall. And all of those operations can be executed by command line, such as installing a feature can use following line:
-application org.eclipse.update.core.standaloneUpdate -command install -featureId my.feature -version 1.0.0 -from file:/v:/local_updateSite/ -to file:/v:/eclipse/.
The installation process would copy the feature and plugins which are included by the feature to the local site from the update site, then execute the feature's global install handler if it has one.

Some strange issue occurs when I want to disable a feature.Then I try to disable the feature with command,
-command disable -featureId my.feature -version 1.0.0 -to file:/v:/eclipse/
The output of command means that the command is executed successfully.
But I list the status of features with command line "-command listFeatures", the status of my.feature is still enable.
Then I try to uninstall my.feature with command,
-command uninstall -featureId my.feature -version 1.0.0 -to file:/v:/eclipse/
It fails, and the following is the root cause found in log file.
!MESSAGE [Cannot find unconfigured feature my.feature with version 1.0.0]
unconfigured feature means the feature is disabled.

I posted my question in forum, and one guy told me that it might be a bug of eclipse and advised me to fire a bug for it.

Thursday, October 19, 2006

[Eclipse]The call sequence between partActivated and menu update

I met a defect that dynamically created menu items disappear after creating a new viewPart. It caused me overtime last Friday. Today I find the root cause.

The scenario is:

  1. open first document, the items are shown well

  2. open another document, the items disappear

The requirement is that showing the menu items while current part is document, otherwise hide them.

So our implementation is:

  1. when current document part is deactivated, set menu items invisible

  2. when document part is activated, set menu items visible


After debugging, I found that menu items was updated before the part activated listener was notified. Hence the menu is invisible while the parent menu is updated. The resolved solution is that setting menu items visible while part opened listener is notified.

Wednesday, October 18, 2006

[debug][java]Remote debug in Eclipse

I need use remote debug in our project, however just some experience in Weblogic were found from internet. After my investigation, I got some experience about using Eclipse remote debug RCP.
There are two important parameters for jvm. And we must launch remote java app with those two parameters.
-Xdebug //tells jvm starting with debug mode
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044 //transport=dt_socket represents communication with socket, address=1044 represents that the port number is 1044
Then there are 3 steps in local env:
1.import source code into eclipse's project
2.Debug-Remote Java Application, see attachement as a sample
3.insert breakpoint,

update:
a simpler way:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000