--- openjdk-orig/jdk/src/solaris/native/sun/xawt/awt_Desktop.c	2012-09-06 18:32:22.752257464 +0300
+++ openjdk/jdk/src/solaris/native/sun/xawt/awt_Desktop.c	2012-09-06 19:00:49.764300607 +0300
@@ -24,53 +24,47 @@
  */
 
 #include <jni.h>
-#include <dlfcn.h>
-
-typedef int gboolean;
-
-gboolean (*gnome_url_show) (const char *url, void **error);
-
-int init(){
-    void *vfs_handle;
-    void *gnome_handle;
-    gboolean (*gnome_vfs_init) (void);
-    const char *errmsg;
-
-    vfs_handle = dlopen("libgnomevfs-2.so.0", RTLD_LAZY);
-    if (vfs_handle == NULL) {
-#ifdef INTERNAL_BUILD
-        fprintf(stderr, "can not load libgnomevfs-2.so\n");
-#endif
-        return 0;
-    }
-    dlerror(); /* Clear errors */
-    gnome_vfs_init = dlsym(vfs_handle, "gnome_vfs_init");
-    if ((errmsg = dlerror()) != NULL) {
-#ifdef INTERNAL_BUILD
-        fprintf(stderr, "can not find symble gnome_vfs_init\n");
-#endif
-        return 0;
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include <fcntl.h>
+
+static int run_program(const char *prog, const char *param) {
+    int success = 0;
+
+    pid_t pid = fork();
+
+    if (pid < 0) {
+        success = 1;
+    } else if (pid == 0) {
+        /* Close stdin, stdout and stderr */
+        int fd = fd = open("/dev/null", O_RDWR);
+        close(0);
+        close(1);
+        close(2);
+        dup2(fd, 0);
+        dup2(fd, 1);
+        dup2(fd, 2);
+        close(fd);
+        execlp(prog, prog, param, NULL);
+        exit(2);
+    } else {
+        int status = 0;
+        pid_t r;
+        while ((r = waitpid(pid, &status, 0)) != pid && errno == EINTR) {
+        }
+        if (r != pid) {
+            success = 4;
+        } else if (!WIFEXITED(status)) {
+            success = 5;
+        } else {
+            success = WEXITSTATUS(status);
+        }
     }
-    // call gonme_vfs_init()
-    (*gnome_vfs_init)();
 
-    gnome_handle = dlopen("libgnome-2.so.0", RTLD_LAZY);
-    if (gnome_handle == NULL) {
-#ifdef INTERNAL_BUILD
-        fprintf(stderr, "can not load libgnome-2.so\n");
-#endif
-        return 0;
-    }
-    dlerror(); /* Clear errors */
-    gnome_url_show = dlsym(gnome_handle, "gnome_url_show");
-    if ((errmsg = dlerror()) != NULL) {
-#ifdef INTERNAL_BUILD
-        fprintf(stderr, "can not find symble gnome_url_show\n");
-#endif
-        return 0;
-    }
+    return success;
 
-    return 1;
 }
 
 /*
@@ -81,8 +75,7 @@
 JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XDesktopPeer_init
   (JNIEnv *env, jclass cls)
 {
-    int init_ok = init();
-    return init_ok ? JNI_TRUE : JNI_FALSE;
+    return run_program("which", "xdg-open") == 0 ? JNI_TRUE : JNI_FALSE;
 }
 
 /*
@@ -93,16 +86,13 @@
 JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XDesktopPeer_gnome_1url_1show
   (JNIEnv *env, jobject obj, jbyteArray url_j)
 {
-    gboolean success;
+    jboolean success;
 
     const char* url_c = (*env)->GetByteArrayElements(env, url_j, NULL);
 
-    if (gnome_url_show == NULL) return JNI_FALSE;
-
-    // call gnome_url_show(const char* , GError**)
-    success = (*gnome_url_show)(url_c, NULL);
+    success = run_program("xdg-open", url_c) == 0 ? JNI_TRUE : JNI_FALSE;
 
     (*env)->ReleaseByteArrayElements(env, url_j, (signed char*)url_c, 0);
 
-    return success ? JNI_TRUE : JNI_FALSE;
+    return success;
 }
