Here’s the command to install an alternative installation of Java:

I installed JDK 6u22 from the executable rpm.bin file from the Oracle site.
Then I ran this command to add it to the alternatives program.

alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_22/bin/java 99

then you just run

alternatives --config java
There are 3 programs which provide 'java'.
Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
   3           /usr/java/jdk1.6.0_22/bin/java
Enter to keep the current selection[+], or type selection number: 3

and select which version of Java you would like to make the system default.

 

Apparently Python 2.7 doesn’t come with setuptools installed, and thus, easy_install doesn’t work. I really miss my OSX, but this new job requires Windows because we have SDKs that we work with that are Windows only. So be sure to download and run ez_setup.py after you install Python 2.7, and then be sure to add C:\Python27\Scripts to your users path so that you can just type easy_install like you all ways could on OSX or Linux.

 

I need to get the PID of a running Java process, in this case Glassfish 3 to see if it is running before I run some asadmin commands.

ps -ax | grep "java -cp /opt/bmam/glassfish" | grep -v "grep" | cut -d " " -f 1
26306
 

If you make changes to your /etc/hosts file and want the changes to take effect immediately without having to reboot issue the following command at in the Terminal

dscacheutil -flushcache

 

Looks like Maven 2 is pretty much inline with the generic Ant based build system I have been using for the past 8 years. So I am going to take the plunge and start using Maven 2 so I don’t have to keep maintaining my system. Less time maintaining a build system means more time writing code that actually does something unique.

 

I am working on a Desktop Application project that will need scripting support, specifically scripting support for people familiar with web development. Even though I have prior experience successfully embedding both Lua and Python in server side applications, I have picked Javascript for this project. Mainly for the low barrier to entry for web developers, and the massive amount of documentation for the language. I am specifically testing out SpiderMonkey right now. I struggled trying to get SpiderMonkey to compile in Xcode 3.2.3 and am documenting how I got it to work. The JSAPI User Guide had some incorrect information, so I updated it with the same information here.

First of I assume you know how to include the headers and the libjs.a library in Xcode 3.2.3. The problem came when I tried to compile the simplest of applications. The fix was you have to include a #define at before the #include “jsapi.h”.
Like so:

#define XP_UNIX
#include "jsapi.h"

Also the line:

global = JS_NewGlobalObject(cx, &global_class, NULL, NULL);

was incorrect as well, it should have been:

global = JS_NewObject(cx, &global_class, NULL, NULL);

Here is the corrected code that will compile and run on Xcode 3.2.3

#define XP_UNIX
#include "jsapi.h"

/* The class of the global object. */
static JSClass global_class = {
    "global", JSCLASS_GLOBAL_FLAGS,
    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
    JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
    JSCLASS_NO_OPTIONAL_MEMBERS
};

/* The error reporter callback. */
void reportError(JSContext *cx, const char *message, JSErrorReport *report)
{
    fprintf(stderr, "%s:%u:%s\n",
            report->filename ? report->filename : "<no filename>",
            (unsigned int) report->lineno,
            message);
}

int main(int argc, const char *argv[])
{
    /* JS variables. */
    JSRuntime *rt;
    JSContext *cx;
    JSObject  *global;
    
    /* Create a JS runtime. */
    rt = JS_NewRuntime(8L * 1024L * 1024L);
    if (rt == NULL)
        return 1;
    
    /* Create a context. */
    cx = JS_NewContext(rt, 8192);
    if (cx == NULL)
        return 1;
    JS_SetOptions(cx, JSOPTION_VAROBJFIX);
    //JS_SetVersion(cx, JSVERSION_LATEST);
    JS_SetErrorReporter(cx, reportError);
    
    /* Create the global object. */
    global = JS_NewObject(cx, &global_class, NULL, NULL);
    if (global == NULL)
        return 1;
    
    /* Populate the global object with the standard globals,
     like Object and Array. */

    if (!JS_InitStandardClasses(cx, global))
        return 1;
    
    //TODO app goes here
    
    /* Cleanup. */
    JS_DestroyContext(cx);
    JS_DestroyRuntime(rt);
    JS_ShutDown();
    return 0;
}

 

I just found this site that lets you see what your pages look like in a bunch of different browsers on a bunch of different operating systems.

 

I just spent a good bit of time searching Google on how to get MacFuse working my 64bit Snow Leopard (10.6.3) machine.
Here is what I found.

MacFuse for Snow Leopard ( 10.6.3 )

You don’t really need MacFusion 2 but it puts a nice interface on MacFuse. It included the SSHFS and FTPFS files systems by default.
MacFusion 2 for Snow Leopard ( 10.6.3 )

The plan is to work on a CouchDBFS implementation.

 

I was getting Out of Memory Error: can't create native thread errors on a server, and it was definately not running out of memory, so I hacked this little program together to tell me how many threads I should be able to create.

64K is the minimum stack size that Java will allow on an Intel platform. OSX 10.6.3 Snow Leopard has a hard coded limit of 2560 threads. Leopard Server doesn’t seem to have this limit.
TestThreadStackSize.java

public class TestThreadStackSizes
{
    public static void main(final String[] args)
    {
        Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            public void uncaughtException(final Thread t, final Throwable e)
            {
                System.err.println(e.getMessage());
                System.exit(1);
            }
        });
        int numThreads = 1000;
        if (args.length == 1)
        {
            numThreads = Integer.parseInt(args[0]);
        }

        for (int i = 0; i < numThreads; i++)
        {
            try
            {
                Thread t = new Thread(new SleeperThread());
                t.start();
            }
            catch (final OutOfMemoryError e)
            {
                throw new RuntimeException(String.format("Out of Memory Error on Thread %d", i), e);
            }
        }
    }

    private static class SleeperThread implements Runnable
    {
        public void run()
        {
            try
            {
                Thread.sleep(1000 * 60 * 60);
            }
            catch (final InterruptedException e)
            {
                throw new RuntimeException(e);
            }
        }
    }
}

 

I am looking at you IE with your non-standard EOT font format. I added an @font-face declaration for my favorite monospace programming font. All Firefox 3.5+, Safari 3.1+, Opera 10+ the latest version of Chrome should now see all the formatted code blocks in the font Inconsolata instead of the default monospace which is what IE will fall back to since I am not going to go to the trouble of support the EOT font format. Sorry IE users complain to Microsoft, they don’t even support the format they bought from Apple in their war against Adobe and PostScript fonts!.

© 2012 Jarrod Roberson: Programming Missives Suffusion theme by Sayontan Sinha