Saturday, June 26, 2010

Profiling Java Application with Netbeans on Ubuntu

Currently this requires installing the "Java Profiler" plugin from within the IDE > Tools > Plugins. Then follow the same steps as for profiling in Windows.

Profiling Java Application with Netbeans on Windows

For profiling with netbeans, I followed the steps as described in the Netbeans IDE 6.8 under "Profile > Profile Project" and "Profile > Attach Profiler". At first, I created a new ant target as:


<target name="run-prof">

<exec dir="${deploy.dir}" executable="cmd" os="Windows 2003" output="runmaster.output.txt">

<env key="HOME" value="C:code">

</env>

<arg line="/c run.bat">

</arg>

</exec></target>


and then to attach the target to the profiler, I replaced the call to "run.bat" with a call to "run_nbproject.bat" as described under the "Attach Profiler" widget. I also set the filters to include "jboss.*".

Tuesday, June 8, 2010

Using JNI with JBoss

For using JNI with JBoss, it is necessary to put the JNI Java wrapper inside the deployment directory of the JBoss server.

I also used the following settings for JNI to work:
  • set java.library.path to include the path to the .so file 
  • set java.ext.dirs to include the path to the .jnilib file (not sure if this is needed)
I did not set the java.library.path variable directly. I wanted to append to this variable and could not find an easy way. Instead the LD_LIBRARY_PATH variable is appended by the JVM into java.library.path. I exploited this. I included the path to the .so in the LD_LIBARY_PATH.