Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail of Java build #416

Closed
nikohansen opened this issue Jan 19, 2016 · 15 comments
Closed

fail of Java build #416

nikohansen opened this issue Jan 19, 2016 · 15 comments
Labels

Comments

@nikohansen
Copy link
Contributor

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.
@ttusar
Copy link
Contributor

ttusar commented Jan 19, 2016

Sorry for the obvious question, but does this machine have Java installed (JDK, not just JRE)?

@nikohansen
Copy link
Contributor Author

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.

@brockho
Copy link
Contributor

brockho commented Jan 19, 2016

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.

@nikohansen
Copy link
Contributor Author

Was not my machine, so I can't try. Agreed, this should certainly go to known issues.

@nikohansen
Copy link
Contributor Author

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."

@ttusar
Copy link
Contributor

ttusar commented Jan 20, 2016

I don't understand this - how?

@nikohansen
Copy link
Contributor Author

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.

@nikohansen
Copy link
Contributor Author

Still one question which should be answered in the requirement readme: Do we need JDK or is JRE sufficient?

@ttusar
Copy link
Contributor

ttusar commented Jan 20, 2016

You need JDK to have javac and javah.

@nikohansen
Copy link
Contributor Author

Now documented in readme.

@markuswagnergithub
Copy link

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!

@ttusar
Copy link
Contributor

ttusar commented Feb 16, 2016

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?

@ttusar ttusar reopened this Feb 16, 2016
@ttusar ttusar added the bug label Feb 16, 2016
@markuswagnergithub
Copy link

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.

@ttusar
Copy link
Contributor

ttusar commented Feb 16, 2016

Good to hear it works for you now! I'll keep the issue open until we find a general fix.
Thanks!

@markuswagnergithub
Copy link

Happy to help :)

@ttusar ttusar mentioned this issue Feb 26, 2016
@ttusar ttusar closed this as completed Feb 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants