I like your solution too. Could you propose that for merging into the main
util-jvm module?

One minor suggestion: generate-java-home.sh should start with a #!/bin/sh
shebang line, I think.

One question: is $(which java)/../.. always JAVA_HOME? Could it be
different if you only have the JRE installed?

Also note that you could do this entirely within CMake if you wanted. Use
FIND_FILE(_JAVA_LOC NAMES java PATHS ENV PATH) (or something similar) to
find the Java command, GET_FILENAME_COMPONENT(_JAVA_LOC "${_JAVA_LOC}"
REALPATH) to resolve to a real location, and then
GET_FILENAME_COMPONENT(_JAVA_HOME "${_JAVA_LOC}/../.." ABSOLUTE) to go up
two directories. (You might be able to combine the last two steps, not
sure.) Not saying that you *should* do that, just letting you know in case
those abilities would be useful in future.

Ceej
aka Chris Hillery

On Wed, Jun 13, 2012 at 8:06 AM, David Graf <david.g...@28msec.com>
wrote:

> Hey Chris
>
> After reading your last comments, I decided to bypass the problem
> differently. Without changing FindJNI.cmake. I generate the JAVA_HOME
> variable with a bash script and set it before searching the JNI stuff.
> Here is the code:
>
>
> 1       === modified file 'runtime/zorba_modules/util-jvm/CMakeLists.txt'
> 2       --- runtime/zorba_modules/util-jvm/CMakeLists.txt       2012-05-22
> 09:45:57 +0000
> 3       +++ runtime/zorba_modules/util-jvm/CMakeLists.txt       2012-06-13
> 13:23:06 +0000
> 4       @@ -23,6 +23,18 @@
> 5          MESSAGE(STATUS "")
> 6          MESSAGE(STATUS "--- Module:   util-jvm    ---")
> 7
> 8       +  # 28msec special
> 9       +  IF (UNIX AND NOT APPLE)
> 10      +    EXECUTE_PROCESS(
> 11      +      COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/generate-java-home.sh
> 12      +      OUTPUT_VARIABLE _JAVA_HOME
> 13      +      RESULT_VARIABLE RES)
> 14      +    IF (RES EQUAL 0)
> 15      +      MESSAGE(STATUS "GENERATED JAVA_HOME: " ${_JAVA_HOME})
> 16      +      set(ENV{JAVA_HOME} ${_JAVA_HOME})
> 17      +    ENDIF()
> 18      +  ENDIF()
> 19      +
> 20         MESSAGE (STATUS "Looking for JNI")
> 21         FIND_PACKAGE(JNI)
> 22
> 23
> 24      === added file
> 'runtime/zorba_modules/util-jvm/generate-java-home.sh'
> 25      --- runtime/zorba_modules/util-jvm/generate-java-home.sh
>  1970-01-01 00:00:00 +0000
> 26      +++ runtime/zorba_modules/util-jvm/generate-java-home.sh
>  2012-06-13 13:23:06 +0000
> 27      @@ -0,0 +1,4 @@
> 28      +WHICH_JAVA=$(which java)
> 29      +RESULT_CODE=$?
> 30      +echo -n $(cd $(dirname $(readlink -f $WHICH_JAVA))/../..; pwd)
> 31      +exit $RESULT_CODE
>
> I like it much more then the other solution. Setting JAVA_HOME is a much
> better idea.
>
> --
> You received this bug notification because you are a bug assignee.
> https://bugs.launchpad.net/bugs/989490
>
> Title:
>  on ubuntu 12.04, Java and/or JNI not found
>
> Status in Zorba - The XQuery Processor:
>  Confirmed
>
> Bug description:
>  Hey Chris
>
>  Java and/or JNI is not found on ubuntu 12.04. Therefore, fop doesn't
>  work. I think the paths to java stuff changed on ubuntu 12.04. Maybe,
>  cmake 2.8.8 is handle those changes. cmake 2.8.7 is not.
>
>  David
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/zorba/+bug/989490/+subscriptions
>

-- 
You received this bug notification because you are a member of Zorba
Coders, which is the registrant for Zorba.
https://bugs.launchpad.net/bugs/989490

Title:
  on ubuntu 12.04, Java and/or JNI not found

Status in Zorba - The XQuery Processor:
  Confirmed

Bug description:
  Hey Chris

  Java and/or JNI is not found on ubuntu 12.04. Therefore, fop doesn't
  work. I think the paths to java stuff changed on ubuntu 12.04. Maybe,
  cmake 2.8.8 is handle those changes. cmake 2.8.7 is not.

  David

To manage notifications about this bug go to:
https://bugs.launchpad.net/zorba/+bug/989490/+subscriptions

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to