--- swig/java/CMakeLists.txt.orig	2012-06-21 09:54:18.000000000 +0200
+++ swig/java/CMakeLists.txt	2012-06-21 09:56:11.000000000 +0200
@@ -12,6 +12,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+IF (WITH_JAVA)
+
 FIND_PACKAGE ( Java )
 INCLUDE ( ${CMAKE_SOURCE_DIR}/cmake_modules/FindJNI.cmake )
 
@@ -45,9 +47,9 @@
 
   # The following fix was added because of the changes in CMake 2.8, which have the
   # result of naming the java binding library "liblibzorba_api.so" instead of "libzorba_api.so"
-  IF (LINUX OR CYGWIN OR APPLE)
+  IF (LINUX OR CYGWIN OR APPLE OR FREEBSD)
     SET_TARGET_PROPERTIES( lib_zorba_java_api PROPERTIES PREFIX "" )
-  ENDIF (LINUX OR CYGWIN OR APPLE)
+  ENDIF (LINUX OR CYGWIN OR APPLE OR FREEBSD)
 
   FILE(GLOB ZORBA_API_HEADERS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/../" "${CMAKE_CURRENT_SOURCE_DIR}/../*.h")
   FOREACH(ZORBA_API_HEADER ${ZORBA_API_HEADERS})
@@ -77,8 +79,8 @@
 		INSTALL(FILES ${JAVA_SWIG_FILES} DESTINATION ${JAVA_SITEARCH_DIR})
   ELSE ( APPLE )
 		IF(NOT WIN32)
-      INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libzorba_api.so DESTINATION ${JAVA_SITEARCH_DIR})
-		  INSTALL(FILES ${JAVA_SWIG_FILES} DESTINATION ${JAVA_SITEARCH_DIR})
+      INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libzorba_api.so DESTINATION ${JAVA_LIBDIR})
+		  INSTALL(FILES ${JAVA_SWIG_FILES} DESTINATION ${JAVA_LIBDIR})
 		ELSE(NOT WIN32)
       IF (MSVC_IDE)
         INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/zorba_api.dll 
@@ -102,3 +104,5 @@
 ELSE (JAVA_INCLUDE_PATH)
   MESSAGE ( STATUS "SWIG: Java binding not generated because JNI was not found.")
 ENDIF (JAVA_INCLUDE_PATH)
+
+ENDIF (WITH_JAVA)
