fail of Java build
nikohansen opened this issue · 15 comments
On an old Linux machine:
python do.py build-java
AML ['code-experiments/src/coco_generics.c', 'code-experiments/src/coco_random.c', 'code-experiments/src/coco_suite.c', 'code-experiments/src/coco_observer.c', 'code-experiments/src/coco_runtime_c.c'] -> code-experiments/build/java/coco.c
COPY code-experiments/src/coco.h -> code-experiments/build/java/coco.h
WRITE code-experiments/build/java/REVISION
WRITE code-experiments/build/java/VERSION
RUN javac CocoJNI.java in code-experiments/build/java
RUN javah CocoJNI in code-experiments/build/java
Traceback (most recent call last):
File "do.py", line 590, in <module>
main(sys.argv[1:])
File "do.py", line 563, in main
elif cmd == 'build-java': build_java()
File "do.py", line 437, in build_java
env = os.environ, universal_newlines = True)
File "/..../code-experiments/tools/cocoutils.py", line 34, in check_output
raise error
subprocess.CalledProcessError: Command '['locate', 'jni.h']' returned non-zero exit status 1
Two points
- resolve the problem and document the resolution here
do.py
should have a verbosity flag. Also, often the call of the executed command from the shell gives more information, which should be somehow suggested to the user.
Sorry for the obvious question, but does this machine have Java installed (JDK, not just JRE)?
I don't know, would in the case
javac CocoJNI.java
work and
javah CocoJNI
fail? Then we should add a requirement to the READMEs.
Can you try the last answer here: http://stackoverflow.com/questions/13526701/javah-missing-after-jdk-install-linux ? Even if this solves the problem, we should probably add a note to the known issues about it.
Was not my machine, so I can't try. Agreed, this should certainly go to known issues.
this suggests that we could get rid of the dependency of javah
?
"The Java Native Interface (JNI) does not require header information or stub files. The javah command can still be used to generate native method function prototypes needed for JNI-style native methods."
I don't understand this - how?
I interpret "can still be used" as "doesn't need to be used anymore". I don't know how though. I have no specific expertise on this.
Still one question which should be answered in the requirement readme: Do we need JDK or is JRE sufficient?
You need JDK to have javac
and javah
.
Now documented in readme.
Hi!
Looks like a pretty comprehensive framework, impressive!
I got stuck under MacOS 10.11.3 with the jni.h problem from above. javah can be found:
Markuss-MBP:bbob2016coco wagner$ ls -l which java
lrwxr-xr-x 1 root wheel 74 6 Nov 19:16 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
Markuss-MBP:bbob2016coco wagner$ ls -l which javah
lrwxr-xr-x 1 root wheel 75 6 Nov 19:16 /usr/bin/javah -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javah
Markuss-MBP:bbob2016coco wagner$ pwd
/Users/wagner/Research/bbob2016coco
Markuss-MBP:bbob2016coco wagner$ javah -version
javah version "1.8.0_40"
Markuss-MBP:bbob2016coco wagner$ javac -version
javac 1.8.0_40
Markuss-MBP:bbob2016coco wagner$ ls
AUTHORS README.md code-postprocessing docs howtos
LICENSE code-experiments do.py doxygen.ini
Markuss-MBP:bbob2016coco wagner$ python do.py run-java
AML ['code-experiments/src/coco_random.c', 'code-experiments/src/coco_suite.c', 'code-experiments/src/coco_observer.c', 'code-experiments/src/coco_runtime_c.c'] -> code-experiments/build/java/coco.c
COPY code-experiments/src/coco.h -> code-experiments/build/java/coco.h
WRITE code-experiments/build/java/REVISION
WRITE code-experiments/build/java/VERSION
RUN javac CocoJNI.java in code-experiments/build/java
RUN javah CocoJNI in code-experiments/build/java
RUN gcc -I /System/Library/Frameworks/JavaVM.framework/Headers -c CocoJNI.c in code-experiments/build/java
ERROR: return value=1
CocoJNI.c:12:10: fatal error: 'jni.h' file not found
#include <jni.h>
^
1 error generated.
Traceback (most recent call last):
File "do.py", line 723, in
main(sys.argv[1:])
File "do.py", line 701, in main
elif cmd == 'run-java': run_java()
File "do.py", line 538, in run_java
build_java()
File "do.py", line 526, in build_java
run('code-experiments/build/java', ['gcc', '-I', jdkpath, '-c', 'CocoJNI.c'])
File "/Users/wagner/Research/bbob2016coco/code-experiments/tools/cocoutils.py", line 103, in run
universal_newlines=True)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 573, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['gcc', '-I', '/System/Library/Frameworks/JavaVM.framework/Headers', '-c', 'CocoJNI.c']' returned non-zero exit status 1
Markuss-MBP:bbob2016coco wagner$ python --version
Python 2.7.10
which is why I am a little stuck even after reading Readme.md. Any ideas? I might be missing something that you have already documented.
Thank you!
Thanks for the detailed report! This problem is indeed different from the documented one. Can you check whether jni.h
is in your /System/Library/Frameworks/JavaVM.framework/Headers
folder?
Alright, so /System/Library/Frameworks/JavaVM.framework/Headers
does not exist on my system! (maybe a change between a major version of MacOS or Java?)
However, based on http://stackoverflow.com/questions/20771803/where-can-i-find-the-jni-headers-for-mac-os the folder
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/
exists on my machine, and it contains jni.h
!
Next step: I updated do.py
with that path in line 525, and I could run python do.py run-java
without an error :)
Not sure if this can be closed now or not. Like I said: I am running MacOS 10.11.3 and Java 1.8, with both being reasonably current.
Good to hear it works for you now! I'll keep the issue open until we find a general fix.
Thanks!
Happy to help :)