Index: /trunk/zoo-project/zoo-kernel/configure.ac
===================================================================
--- /trunk/zoo-project/zoo-kernel/configure.ac	(revision 766)
+++ /trunk/zoo-project/zoo-kernel/configure.ac	(revision 767)
@@ -587,5 +587,7 @@
 	then
 		JAVA_LDFLAGS="-framework JavaVM"
-		JAVA_CPPFLAGS="-I/Applications/Xcode.app/Contents/Developer//Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/"
+		for i in `ls /Applications/Xcode.app/Contents/Developer//Platforms/MacOSX.platform/Developer/SDKs/`; do
+		    JAVA_CPPFLAGS="-I/Applications/Xcode.app/Contents/Developer//Platforms/MacOSX.platform/Developer/SDKs/$i/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/"
+		done
 	else
 		if test -d "$JDKHOME/jre/lib/i386";
@@ -594,9 +596,16 @@
 			JAVA_CPPFLAGS="-I$JDKHOME/include -I$JDKHOME/include/linux"
 		else
-			JAVA_LDFLAGS="-L$JDKHOME/jre/lib/amd64/server/ -ljvm -lpthread"
-			JAVA_CPPFLAGS="-I$JDKHOME/include -I$JDKHOME/include/linux"
+			if test -d "$JDKHOME/jre/lib/amd64"; then
+			   JAVA_LDFLAGS="-L$JDKHOME/jre/lib/amd64/server/ -ljvm -lpthread"
+			   JAVA_CPPFLAGS="-I$JDKHOME/include -I$JDKHOME/include/linux"
+			else
+			   JAVA_LDFLAGS="-L$JDKHOME/jre/lib/server/ -ljvm -lpthread"
+			   JAVA_CPPFLAGS="-I$JDKHOME/include/ -I$JDKHOME/include/darwin"
+			fi
 		fi
 	fi
 
+	AC_LANG([C++])
+	echo $JAVA_CPPFLAGS
 	# Check headers file (second time we check that in fact)
 	CPPFLAGS_SAVE="$CPPFLAGS"
@@ -604,5 +613,5 @@
 	AC_CHECK_HEADERS([jni.h],
 			 [], [AC_MSG_ERROR([could not find jni.h file])])
-
+	CPPFLAGS="$CPPFLAGS_SAVE"
 	# Ensure we can link against libjava
 	LIBS_SAVE="$LIBS"
Index: /trunk/zoo-project/zoo-kernel/request_parser.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/request_parser.h	(revision 766)
+++ /trunk/zoo-project/zoo-kernel/request_parser.h	(revision 767)
@@ -31,9 +31,10 @@
 #include "ulinet.h"
 
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
-#include <libxml/parser.h>
-#include <libxml/xpath.h>
 
   xmlXPathObjectPtr extractFromDoc (xmlDocPtr, const char *);
Index: /trunk/zoo-project/zoo-kernel/response_print.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/response_print.h	(revision 766)
+++ /trunk/zoo-project/zoo-kernel/response_print.h	(revision 767)
@@ -92,10 +92,10 @@
 #include <openssl/buffer.h>
 
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
-#include <libxml/parser.h>
-#include <libxml/xpath.h>
-
   /**
    * Maximum number of XML namespaces
Index: /trunk/zoo-project/zoo-kernel/server_internal.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/server_internal.h	(revision 766)
+++ /trunk/zoo-project/zoo-kernel/server_internal.h	(revision 767)
@@ -38,9 +38,10 @@
 extern   int conf_read(const char*,maps*);
 
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
-#include <libxml/parser.h>
-#include <libxml/xpath.h>
 
   char *get_uuid();  
Index: /trunk/zoo-project/zoo-kernel/service.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/service.h	(revision 766)
+++ /trunk/zoo-project/zoo-kernel/service.h	(revision 767)
@@ -112,17 +112,5 @@
 #ifndef WIN32
 #include <ctype.h>
-#ifndef bool
-#define bool int
-#endif
-#ifndef true
-  /**
-   * Local true definition
-   */
-#define true 1
-  /**
-   * Local false definition
-   */
-#define false 0
-#endif
+#include <stdbool.h>
 #endif
 
Index: /trunk/zoo-project/zoo-kernel/service_internal_java.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_java.c	(revision 766)
+++ /trunk/zoo-project/zoo-kernel/service_internal_java.c	(revision 767)
@@ -40,6 +40,8 @@
   maps* inputs=*real_inputs;
   maps* outputs=*real_outputs;
-  char ntmp[1024];
-  getcwd(ntmp,1024);
+  map* cwdMap=getMapFromMaps(*main_conf,"lenv","cwd");
+  char *ntmp=NULL;
+  if(cwdMap!=NULL)
+    ntmp=zStrdup(cwdMap->value);
   map* tmp=getMap(request,"metapath");
   char *classpath;
@@ -80,11 +82,15 @@
   }
   sprintf(oclasspath,"-Djava.class.path=%s",classpath);
-
 #ifdef DEBUG
   fprintf(stderr,"CLASSPATH=%s\n",classpath);
   fprintf(stderr,"(%s)\n",oclasspath);
 #endif
+#ifndef USE_JDB
+  int njdb=0;
+#else
+  int njdb=2;
+#endif
 #ifndef WIN32
-  int nb=1;
+  int nb=3+njdb;
 #endif
   int nbc0=0;
@@ -125,9 +131,22 @@
   options[0].optionString = oclasspath;
   options[0].extraInfo=NULL;
+  options[1].optionString = "-server";
+  options[1].extraInfo=NULL;
+  char tmp1[100];
+  sprintf(tmp1,"-Djava.library.path=%s",cwdMap->value);
+  fprintf(stderr,"%s\n",tmp1);
+  options[2].optionString = tmp1;
+  options[2].extraInfo=NULL;
+#ifdef USE_JDB
+  options[3].optionString = "-Xdebug";
+  options[3].extraInfo=NULL;
+  options[4].optionString = "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7896";
+  options[4].extraInfo=NULL;
+#endif
 #ifdef WIN32
   start=2;
   options[1].optionString = "-Xmx512m";
 #else
-  start=1;
+  start=3+njdb;
 #endif
   for(i=0;i<nbc0;i++){
@@ -164,9 +183,7 @@
   tmp=getMap(s->content,"serviceProvider");
 #ifdef JAVA7
-  cls = env->FindClass(tmp->value);
-  cls_gr = env->NewGlobalRef(cls);
+  cls = (*env).FindClass(tmp->value);
 #else
   cls = (*env)->FindClass(env,tmp->value);
-  cls_gr = (*env)->NewGlobalRef(env, cls);
 #endif
   if( cls == NULL ) {
@@ -183,4 +200,9 @@
     fprintf(stderr,"%s loaded\n",tmp->value);
   }
+#endif
+#ifdef JAVA7
+  cls_gr = (*env)NewGlobalRef(cls);
+#else
+  cls_gr = (*env)->NewGlobalRef(env, cls);
 #endif
 
@@ -246,4 +268,5 @@
       displayStack(env,*main_conf);
 #ifdef JAVA7
+      (*env).ExceptionDescribe();
       (*jvm).DestroyJavaVM();
 #else
@@ -324,5 +347,5 @@
   if(strncasecmp(m->value,"minus",5)==0)
     sprintf(res,"-XX:-%s",m->name);
-  else if(strncasecmp(m->value,"plus",5)==0)
+  else if(strncasecmp(m->value,"plus",4)==0)
     sprintf(res,"-XX:+%s",m->name);
   else
@@ -393,8 +416,8 @@
 	      jbyteArray tmpData=(*env).NewByteArray(atoi(sizeV->value));
 	      (*env).SetByteArrayRegion(tmpData,0,atoi(sizeV->value),(const jbyte *)tmp1->value);
-	      (*env).CallObjectMethod(scObject1, put_mid, (*env).NewStringUTF(tmp1->name), tmpData);
+	      (*env).CallObjectMethod(env,scObject1, put_mid, (*env).NewStringUTF(env,tmp1->name), tmpData);
 #else
 	      jbyteArray tmpData=(*env)->NewByteArray(env,atoi(sizeV->value));
-	      (*env)->SetByteArrayRegion(env,tmpData,0,atoi(sizeV->value),tmp1->value);
+	      (*env)->SetByteArrayRegion(env,tmpData,0,atoi(sizeV->value),(jbyte*) tmp1->value);
 	      (*env)->CallObjectMethod(env,scObject1, put_mid, (*env)->NewStringUTF(env,tmp1->name), tmpData);
 #endif
Index: /trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 766)
+++ /trunk/zoo-project/zoo-kernel/zoo_service_loader.c	(revision 767)
@@ -34,6 +34,4 @@
 #include "cgic.h"
 
-extern "C"
-{
 #include <libxml/tree.h>
 #include <libxml/xmlmemory.h>
@@ -41,5 +39,4 @@
 #include <libxml/xpath.h>
 #include <libxml/xpathInternals.h>
-}
 
 #include "ulinet.h"
@@ -1722,9 +1719,9 @@
 #ifndef WIN32
           setenv (mapcs->name, mapcs->value, 1);
-#else
 #ifdef DEBUG
           fprintf (stderr, "[ZOO: setenv (%s=%s)]\n", mapcs->name,
                    mapcs->value);
 #endif
+#else
           if (mapcs->value[strlen (mapcs->value) - 2] == '\r')
             {
@@ -1746,6 +1743,4 @@
             }
 #else
-
-
           SetEnvironmentVariable (mapcs->name, mapcs->value);
 #endif
