Index: gen_bindings.php
===================================================================
--- gen_bindings.php	(revision 505)
+++ gen_bindings.php	(revision 506)
@@ -241,11 +241,113 @@
 }
 
 
+function swig_wrappers_java()
+{
+
+$maps=<<<EOS
+
+%javaconst(1);
+
+%typemap(jni) signed char, const signed char & 		"jint"
+%typemap(jtype) signed char, const signed char &	"int"
+%typemap(jstype) signed char, const signed char & 	"int"
+
+%typemap(in) (int argc, char **argv) {
+// This typemap create a dummy first arg, since Java does not provide
+// the usual C argv[0]
+    int i = 0;
+    \$1 = (*jenv)->GetArrayLength(jenv, \$input);
+    \$2 = (char **) malloc((\$1+2)*sizeof(char *));
+
+    \$2[0] = malloc((strlen("(dummy)")+1)*sizeof(const char *));
+    strcpy(\$2[0],"(dummy)");
+    /* make a copy of each string */
+    for (i = 0; i<\$1; i++) {
+        jstring j_string = (jstring)(*jenv)->GetObjectArrayElement(jenv, \$input, i);
+        const char * c_string = (*jenv)->GetStringUTFChars(jenv, j_string, 0);
+        \$2[i+1] = malloc(strlen((c_string)+1)*sizeof(const char *));
+        strcpy(\$2[i+1], c_string);
+        (*jenv)->ReleaseStringUTFChars(jenv, j_string, c_string);
+        (*jenv)->DeleteLocalRef(jenv, j_string);
+    }
+    \$2[i+1] = 0;
+    \$1++;
+}
+
+%typemap(freearg) (int argc, char **argv) {
+    int i;
+    for (i=0; i<\$1-1; i++)
+      free(\$2[i]);
+    free(\$2);
+}
+
+%typemap(jni) (int argc, char **argv) "jobjectArray"
+%typemap(jtype) (int argc, char **argv) "String[]"
+%typemap(jstype) (int argc, char **argv) "String[]"
+%typemap(javain) (int argc, char **argv) "\$javainput"
+
+EOS;
+
+if(chdir("raydium/swig")===false)
+    die("not in Raydium's root dir, cannot find swig dir\n");
+
+
+@mkdir("org",0755);
+@mkdir("org/raydium",0755);
+    
+$fp=fopen("raydium.i","rt");
+$contents = '';
+while (!feof($fp))
+    {
+    $contents .= fread($fp, 8192);
+    }
+fclose($fp);
+		
+$fp=fopen("org/raydium/raydium.i","wt");
+fwrite($fp,$maps."\n".$contents);
+fclose($fp);
+
+
+passthru("swig -java -package org.raydium org/raydium/raydium.i",$ret);
+echo "\n";
+if($ret!=0)
+    die("");
+
+
+chdir("../..");
+echo "Java source code generated, you must now compile it:\n";
+echo "# cd raydium/swig\n";
+echo "# javac org/raydium/*.java\n";
+echo "# rm -f org/raydium/*.java\n";
+echo "# jar cf raydium.jar\n";
+echo "# cd ../..\n";
+echo "\n";
+echo "You must now compile the native Raydium lib.\n";
+echo "Compile example (see ocomp.sh for up to date gcc args) for Java:\n";
+echo "gcc -g -Wall -shared raydium/swig/org/raydium/raydium_wrap.c -o raydium/swig/libraydium.so  -L/usr/X11R6/lib/ -lXinerama -lGL -lGLU -lm -lopenal -lalut -ljpeg -Iraydium/ode/include/ raydium/ode/lib/libode.a -lvorbis -lvorbisfile -logg -Iraydium/php/ -Iraydium/php/include -Iraydium/php/main/ -Iraydium/php/Zend -Iraydium/php/TSRM raydium/php/libs/libphp5.a -lresolv -lcrypt -lz -lcurl -lxml2 -lGLEW -I/opt/java_ee_sdk-5_02/jdk/include/ -I/opt/java_ee_sdk-5_02/jdk/include/linux";
+echo "\n\n";
+echo "You must probably change the two endings Java include paths (-I...) in this command line.\n";
+echo "(Unix users: do not forget LD_LIBRARY_PATH at runtime ...)\n";
+}
+
 ///////////// "main"
-generate_interface_file();
 
-//swig_wrappers_perl();
-swig_wrappers_python();
+$arg1=$_SERVER['argv'][1];
+if($arg1=="")
+    die("Raydium bindings generator:\nUsage: gen_bindings.php [--java|--python]\n");
 
+switch($arg1)
+    {
+    case "--python":
+	generate_interface_file();
+	swig_wrappers_python();
+    break;
 
-
+    case "--java":
+	generate_interface_file();
+	swig_wrappers_java();
+    break;
+    
+    default:
+	echo "error: invalid argument '$arg1'\n";
+    }