diff -r bee43070e71d Makefile.am
--- a/Makefile.am	Fri Feb 18 11:55:23 2011 -0500
+++ b/Makefile.am	Fri Feb 18 14:25:40 2011 -0500
@@ -17,6 +17,10 @@
 IT_CLASS_TARGET_VERSION=6
 IT_JAVACFLAGS=$(IT_JAVAC_SETTINGS) -source $(IT_LANGUAGE_SOURCE_VERSION) -target $(IT_CLASS_TARGET_VERSION)
 
+JRE='"$(SYSTEM_JDK_DIR)jre"'
+LAUNCHER_BOOTCLASSPATH="-J-Xbootclasspath/a:$(DESTDIR)$(datadir)/$(PACKAGE_NAME)/netx.jar"
+PLUGIN_BOOTCLASSPATH='"-Xbootclasspath/a:$(DESTDIR)$(datadir)/$(PACKAGE_NAME)/netx.jar:$(DESTDIR)$(datadir)/$(PACKAGE_NAME)/plugin.jar"'
+
 # Fake update version to shut up the plugin detector hosted by Oracle.
 # If Oracle ever release a JDK update greater than 50, this needs to be increased.
 JDK_UPDATE_VERSION=50
@@ -94,36 +98,20 @@
  clean-bootstrap-directory clean-native-ecj clean-desktop-files clean-netx-docs clean-docs clean-plugin-docs
 
 install-exec-local:
-	${mkinstalldirs} $(DESTDIR)$(bindir) $(DESTDIR)$(prefix)/jre/lib/$(INSTALL_ARCH_DIR)
+	${mkinstalldirs} $(DESTDIR)$(bindir) $(DESTDIR)$(datadir)/$(PACKAGE_NAME)/ $(DESTDIR)$(libdir)
 if ENABLE_PLUGIN
-	${INSTALL_PROGRAM} $(PLUGIN_DIR)/IcedTeaPlugin.so $(DESTDIR)$(prefix)/jre/lib/$(INSTALL_ARCH_DIR)/
-	${INSTALL_DATA} $(abs_top_builddir)/liveconnect/lib/classes.jar $(DESTDIR)$(prefix)/jre/lib/plugin.jar
+	${INSTALL_PROGRAM} $(PLUGIN_DIR)/IcedTeaPlugin.so $(DESTDIR)$(libdir)
+	${INSTALL_DATA} $(abs_top_builddir)/liveconnect/lib/classes.jar $(DESTDIR)$(datadir)/$(PACKAGE_NAME)/plugin.jar
 endif
-	${INSTALL_DATA} $(NETX_DIR)/lib/classes.jar $(DESTDIR)$(prefix)/jre/lib/netx.jar
+	${INSTALL_DATA} $(NETX_DIR)/lib/classes.jar $(DESTDIR)$(datadir)/$(PACKAGE_NAME)/netx.jar
 	${INSTALL_PROGRAM} $(NETX_DIR)/launcher/javaws $(DESTDIR)$(bindir)
-	if [ -d $(DESTDIR)$(prefix)/jre/bin ] ; then \
-	  if [ -L $(DESTDIR)$(prefix)/jre/bin/javaws ] ; then \
-	    rm -f $(DESTDIR)$(prefix)/jre/bin/javaws ; \
-	  fi ; \
-	  if [ ! -e $(prefix)/jre/bin/javaws ] ; then \
-	    ln -s $(DESTDIR)$(bindir)/javaws $(DESTDIR)$(prefix)/jre/bin ; \
-	  fi ; \
-	fi
-	${INSTALL_DATA} extra-lib/about.jar $(DESTDIR)$(prefix)/jre/lib
+	${INSTALL_DATA} extra-lib/about.jar $(DESTDIR)$(datadir)/$(PACKAGE_NAME)/about.jar
 	${INSTALL_PROGRAM} $(NETX_DIR)/launcher/controlpanel/itweb-settings $(DESTDIR)$(bindir)
-	if [ -d $(DESTDIR)$(prefix)/jre/bin ] ; then \
-	  if [ -L $(DESTDIR)$(prefix)/jre/bin/itweb-settings ] ; then \
-	    rm -f $(DESTDIR)$(prefix)/jre/bin/itweb-settings ; \
-	  fi ; \
-	  if [ ! -e $(prefix)/jre/bin/itweb-settings ] ; then \
-	    ln -s $(DESTDIR)$(bindir)/itweb-settings $(DESTDIR)$(prefix)/jre/bin ; \
-	  fi ; \
-	fi
 
 install-data-local:
 	${mkinstalldirs} -d $(DESTDIR)$(prefix)/man/man1
 	${INSTALL_DATA} $(NETX_SRCDIR)/javaws.1 $(DESTDIR)$(prefix)/man/man1
-	${INSTALL_DATA} $(NETX_RESOURCE_DIR)/about.jnlp $(DESTDIR)$(prefix)/jre/lib
+	${INSTALL_DATA} $(NETX_RESOURCE_DIR)/about.jnlp $(DESTDIR)$(datarootdir)/$(PACKAGE_NAME)
 if ENABLE_DOCS
 	${mkinstalldirs} $(DESTDIR)$(htmldir)
 	(cd ${abs_top_builddir}/docs/netx; \
@@ -141,21 +129,14 @@
 endif
 
 uninstall-local:
-	rm -f $(DESTDIR)$(prefix)/jre/lib/$(INSTALL_ARCH_DIR)/IcedTeaPlugin.so
-	rm -f $(DESTDIR)$(prefix)/jre/lib/plugin.jar
-	rm -f $(DESTDIR)$(prefix)/jre/lib/netx.jar
-	rm -f $(DESTDIR)$(prefix)/jre/lib/about.jnlp
-	rm -f $(DESTDIR)$(prefix)/jre/lib/about.jar
+	rm -f $(DESTDIR)$(libdir)/IcedTeaPlugin.so
+	rm -f $(DESTDIR)$(datadir)/$(PACKAGE_NAME)/plugin.jar
+	rm -f $(DESTDIR)$(datadir)/$(PAKCAGE_NAME)/netx.jar
+	rm -f $(DESTDIR)$(datadir)/$(PACKAGE_NAME)/about.jnlp
+	rm -f $(DESTDIR)$(datadir)/$(PACKAGE_NAME)/about.jar
 	rm -f $(DESTDIR)$(prefix)/man/man1/javaws.1
 	rm -f $(DESTDIR)$(bindir)/javaws
-	if [ -L $(DESTDIR)$(prefix)/jre/bin/javaws ] ; then \
-	  rm -f $(DESTDIR)$(prefix)/jre/bin/javaws ; \
-	fi
-	rm -f $(DESTDIR)$(prefix)/jre/bin/javaws
 	rm -f $(DESTDIR)$(bindir)/itweb-settings
-	if [ -L $(DESTDIR)$(prefix)/jre/bin/itweb-settings ] ; then \
-	  rm -f $(DESTDIR)$(prefix)/jre/bin/itweb-settings ; \
-	fi
 	rm -rf $(DESTDIR)$(htmldir)
 
 # Plugin
@@ -183,6 +164,8 @@
 	  -DPLUGIN_VERSION="\"$(PLUGIN_VERSION)\"" \
 	  -DPACKAGE_URL="\"$(PACKAGE_URL)\"" \
 	  -DMOZILLA_VERSION_COLLAPSED="$(MOZILLA_VERSION_COLLAPSED)" \
+	  -DICEDTEA_WEB_JRE=$(JRE) \
+	  -DPLUGIN_BOOTCLASSPATH=$(PLUGIN_BOOTCLASSPATH) \
 	  $(GLIB_CFLAGS) \
 	  $(GTK_CFLAGS) \
 	  $(MOZILLA_CFLAGS) \
@@ -328,14 +311,14 @@
 $(NETX_DIR)/launcher/%.o: $(LAUNCHER_SRCDIR)/%.c
 	mkdir -p $(NETX_DIR)/launcher && \
 	$(CC) $(LAUNCHER_FLAGS) \
-	  -DJAVA_ARGS='{ "-J-ms8m", "-J-Djava.icedtea-web.bin=$(DESTDIR)$(bindir)/javaws", "net.sourceforge.jnlp.runtime.Boot",  }' \
-	  -DPROGNAME='"javaws"' -c -o $@ $<
+	  -DJAVA_ARGS='{ $(LAUNCHER_BOOTCLASSPATH), "-J-ms8m", "-J-Djava.icedtea-web.bin=$(DESTDIR)$(bindir)/javaws", "net.sourceforge.jnlp.runtime.Boot",  }' \
+	  -DICEDTEA_WEB_JRE=$(JRE) -DPROGNAME='"javaws"' -c -o $@ $<
 
 $(NETX_DIR)/launcher/controlpanel/%.o: $(LAUNCHER_SRCDIR)/%.c
 	mkdir -p $(NETX_DIR)/launcher/controlpanel && \
 	$(CC) $(LAUNCHER_FLAGS) \
-	-DJAVA_ARGS='{ "-J-ms8m", "-Dprogram.name=itweb-settings", "net.sourceforge.jnlp.controlpanel.CommandLine",  }' \
-	-DPROGNAME='"itweb-settings"' -c -o $@ $<
+	-DJAVA_ARGS='{ $(LAUNCHER_BOOTCLASSPATH), "-J-ms8m", "-Dprogram.name=itweb-settings", "net.sourceforge.jnlp.controlpanel.CommandLine",  }' \
+	-DICEDTEA_WEB_JRE=$(JRE) -DPROGNAME='"itweb-settings"' -c -o $@ $<
 
 $(NETX_DIR)/launcher/javaws: $(NETX_LAUNCHER_OBJECTS)
 	$(CC) $(NETX_LAUNCHER_OBJECTS) $(LAUNCHER_LINK)
diff -r bee43070e71d launcher/java_md.c
--- a/launcher/java_md.c	Fri Feb 18 11:55:23 2011 -0500
+++ b/launcher/java_md.c	Fri Feb 18 14:25:40 2011 -0500
@@ -158,6 +158,7 @@
 static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
                            char *jvmpath, jint jvmpathsize, char * arch);
 static jboolean GetJREPath(char *path, jint pathsize, char * arch, jboolean speculative);
+static jboolean GetIcedTeaWebJREPath(char *path, jint pathsize, char * arch, jboolean speculative);
 
 const char *
 GetArch()
@@ -280,7 +281,7 @@
          jvmpath does not exist */
       if (wanted == running) {
         /* Find out where the JRE is that we will be using. */
-        if (!GetJREPath(jrepath, so_jrepath, arch, JNI_FALSE) ) {
+        if (!GetIcedTeaWebJREPath(jrepath, so_jrepath, arch, JNI_FALSE) ) {
           fprintf(stderr, "Error: could not find Java 2 Runtime Environment.\n");
           exit(2);
         }
@@ -606,6 +607,33 @@
 }
 
 /*
+ * Find path to the JRE based on the the compile flag ICEDTEA_WEB_JRE
+ */
+static jboolean
+GetIcedTeaWebJREPath(char* path, jint pathsize, char* arch, jboolean speculative)
+{
+    char libjava[MAXPATHLEN];
+    snprintf(libjava, MAXPATHLEN, ICEDTEA_WEB_JRE "/lib/%s/" JAVA_DLL, arch);
+
+    if (_launcher_debug) {
+      printf(ICEDTEA_WEB_JRE "/lib/%s/" JAVA_DLL "\n", arch);
+      printf("libjava is %s\n", libjava);
+    }
+
+    if (access(libjava, F_OK) == 0) {
+        strncpy(path, ICEDTEA_WEB_JRE, pathsize);
+        goto found;
+    }
+
+    return JNI_FALSE;
+
+ found:
+    if (_launcher_debug)
+      printf("JRE path is %s\n", path);
+    return JNI_TRUE;
+}
+
+/*
  * Find path to JRE based on .exe's location or registry settings.
  */
 static jboolean
diff -r bee43070e71d plugin/icedteanp/IcedTeaNPPlugin.cc
--- a/plugin/icedteanp/IcedTeaNPPlugin.cc	Fri Feb 18 11:55:23 2011 -0500
+++ b/plugin/icedteanp/IcedTeaNPPlugin.cc	Fri Feb 18 14:25:40 2011 -0500
@@ -1547,23 +1547,25 @@
 
   if (plugin_debug)
   {
-      command_line = (gchar**) malloc(sizeof(gchar*)*8);
+      command_line = (gchar**) malloc(sizeof(gchar*)*9);
       command_line[0] = g_strdup(appletviewer_executable);
-      command_line[1] = g_strdup("-Xdebug");
-      command_line[2] = g_strdup("-Xnoagent");
-      command_line[3] = g_strdup("-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n");
-      command_line[4] = g_strdup("sun.applet.PluginMain");
-      command_line[5] = g_strdup(out_pipe_name);
-      command_line[6] = g_strdup(in_pipe_name);
-      command_line[7] = NULL;
+      command_line[1] = g_strdup(PLUGIN_BOOTCLASSPATH);
+      command_line[2] = g_strdup("-Xdebug");
+      command_line[3] = g_strdup("-Xnoagent");
+      command_line[4] = g_strdup("-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n");
+      command_line[5] = g_strdup("sun.applet.PluginMain");
+      command_line[6] = g_strdup(out_pipe_name);
+      command_line[7] = g_strdup(in_pipe_name);
+      command_line[8] = NULL;
    } else
    {
-       command_line = (gchar**) malloc(sizeof(gchar*)*5);
+       command_line = (gchar**) malloc(sizeof(gchar*)*6);
        command_line[0] = g_strdup(appletviewer_executable);
-       command_line[1] = g_strdup("sun.applet.PluginMain");
-       command_line[2] = g_strdup(out_pipe_name);
-       command_line[3] = g_strdup(in_pipe_name);
-       command_line[4] = NULL;
+       command_line[1] = g_strdup(PLUGIN_BOOTCLASSPATH);
+       command_line[2] = g_strdup("sun.applet.PluginMain");
+       command_line[3] = g_strdup(out_pipe_name);
+       command_line[4] = g_strdup(in_pipe_name);
+       command_line[5] = NULL;
    }
 
   environment = plugin_filter_environment();
@@ -1590,17 +1592,21 @@
   command_line[0] = NULL;
   g_free (command_line[1]);
   command_line[1] = NULL;
+  g_free (command_line[2]);
+  command_line[2] = NULL;
+  g_free (command_line[3]);
+  command_line[3] = NULL;
+  g_free (command_line[4]);
+  command_line[4] = NULL;
 
   if (plugin_debug)
   {
-      g_free (command_line[2]);
-      command_line[2] = NULL;
-      g_free (command_line[3]);
-      command_line[3] = NULL;
-      g_free (command_line[4]);
-      command_line[4] = NULL;
       g_free (command_line[5]);
       command_line[5] = NULL;
+      g_free (command_line[6]);
+      command_line[6] = NULL;
+      g_free (command_line[7]);
+      command_line[7] = NULL;
   }
 
   g_free(command_line);
@@ -2173,38 +2179,10 @@
     }
 
   // Set appletviewer_executable.
-  Dl_info info;
-  int filename_size;
-  if (dladdr ((const void*) ITNP_New, &info) == 0)
-    {
-      PLUGIN_ERROR_TWO ("Failed to determine plugin shared object filename",
-                        dlerror ());
-      np_error = NPERR_GENERIC_ERROR;
-      goto cleanup_data_directory;
-    }
-  filename = (gchar*) malloc(sizeof(gchar)*1024);
-  filename_size = readlink(info.dli_fname, filename, 1023);
-  if (filename_size >= 0)
-  {
-      filename[filename_size] = '\0';
-  }
-
-  if (!filename)
-    {
-      PLUGIN_ERROR ("Failed to create plugin shared object filename.");
-      np_error = NPERR_OUT_OF_MEMORY_ERROR;
-      goto cleanup_data_directory;
-    }
-
-  if (filename_size <= 0)
-  {
-      free(filename);
-      filename = g_strdup(info.dli_fname);
-  }
-
-  appletviewer_executable = g_strdup_printf ("%s/../../bin/java",
-                                             dirname (filename));
-  PLUGIN_DEBUG(".so is located at: %s and the link points to: %s. Executing java from dir %s to run %s\n", info.dli_fname, filename, dirname (filename), appletviewer_executable);
+  filename = g_strdup(ICEDTEA_WEB_JRE);
+  appletviewer_executable = g_strdup_printf ("%s/bin/java",
+                                             filename);
+  PLUGIN_DEBUG("Executing java at %s\n", appletviewer_executable);
   if (!appletviewer_executable)
     {
       PLUGIN_ERROR ("Failed to create appletviewer executable name.");