JAVA_HOME and java.library.path

I’m working on a project where I need to set the JAVA_HOME path. Typing which java in the terminal, I get “/usr/bin/java”, but this is actually not the java_home. The right way is to use sudo /usr/libexec/java_home and then input the password of the administrative account of your computer as requested, you will get the java_home path. Mine (OSX Snow Leopard 10.6.8) is /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

Then you can use JAVA_HOME=$(/usr/libexec/java_home) to set the java_home path, without literally typing the exact path.
You can then use either echo $JAVA_HOME or env | grep JAVA_HOME to confirm the path.

Another issue I had is with the java.library.path when using Eclipse. Even though I have included all the .jar files in the Eclipse project, I still got UnsatisfiedLinkError in Eclipse saying something is not found in the java.library.path. I had to add an .jnilib file in to the java library path. The safe way to do so without messing up with the java.library.path is to create a new user library in Eclipse project–>properties–>build path. After you create the new user library, click the arrow on the left of the new library title in the following dialog, and change the “native library location” from none to where the .jnilib file is located. Problems solved!


JQuery Dialog Button Text Not Working and Others

After spending Saturday afternoon, Saturday night (until 3:30am), and Sunday morning coding on IKNEER, I figured out 3 things:
1. How to add a pop-up dialog window in an existing JavaScript table cell.

<div id=dialogForm></div> //this is in the .php file
var $dialog = $('#dialogForm').dialog({ });
var dialogForm=document.getElementById("dialogForm");
var dialogFormWin = new DialogFormWindow(null);

2. Because the existing table has 10 rows, so my pop-up window will have 10 iterative rows too. If I move the window into the click function, there will be accumulated rows in the pop-up window depending on how many times I click the button to show the window. So I have to remove the previous content upon clicking.

var dialogForm=document.getElementById("dialogForm");
if (dialogForm.hasChildNodes()) 

3. The third problem is the one cost me most of the time. I had this problem last week, and just decided to put it away for a while, this weekend I solved it! The JQuery dialog box button text doesn’t work.

var $dialog = $('#dialogForm').dialog({
             autoOpen: false, 
             "Cancel":function() {$('#dialogForm').dialog( "close");},
             "Save":function() {$('#dialogForm').dialog( "close" );}

If I use the code above, the text “Cancel” and “Save” wouldn’t show up. Debugging using Firebug on FireFox, I get:

<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="button">
<span class='ui-button-text'></span></button>

It has a text=”Save” attribute, but in the <span></span> tag, there is no text.

I found people have had the same problem before:

I actually also has the other same problem with the button showing 0 and 1 when using buttons as array rather than object.

There seems no easy solution to solve the possible inconsistency or conflict in the jQuery/jQuery-UI library. So I have to insert the text to the <span></span> tag.

There is an inspiring answer on StackOverFlow (this seems a good Q&A place for programmer, where I will go more often in the future) posted by a user on StackOverFlow named conceptacid:

$('div.ui-dialog-buttonset button.ui-button ui-button-text').each(function() {
$(this).html(<span class="ui-button-text">+"$(this).parent().attr('text')'+</span>");})

This didn’t work for my code, and after spending a long time wondering why, I modified it like this:

$('div.ui-dialog-buttonset button.ui-button span.ui-button-text').each(function() {

It works! I posted the answer to StackOverFlow