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

Setting bootclasspath for cross-compiling on Java 8. #745

Closed
wants to merge 1 commit into from

Conversation

senderista
Copy link
Contributor

After compiling Myria binaries on my laptop with Java 8 installed, I got mysterious errors after deployment which turned out to be due to not setting the -bootclasspath option tojavac. See this article for explanation: https://blogs.oracle.com/darcy/entry/how_to_cross_compile_for. To cross-compile correctly from a newer JDK version to an older one, it is not enough to set -source and -target options as we do currently; we also have to set the boot classpath (where the javac class loader looks for "bootstrap" libraries). With this change, to build Myria on a system with Java 8 installed, you must install JDK 7 and set the JAVA7_HOME environment variable to the location of your JDK. On a Mac, this can be done properly by adding the following to your .zshenv or .bashrc:
export JAVA7_HOME=$(/usr/libexec/java_home -v 1.7)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.17%) to 59.58% when pulling 60296b3 on cross_compile into 54d54b9 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 59.39% when pulling 60296b3 on cross_compile into 54d54b9 on master.

@jingjingwang
Copy link
Contributor

Also, from the link that you gave, seems not doing a cross-compile is the best way:
"The most reliably way to produce class files that will work on a particular JDK and later is to compile the source files using the oldest JDK of interest. ..."

@senderista
Copy link
Contributor Author

I've tried the other approach of setting JAVA_HOME to the non-default JDK for a particular build and it was far more trouble than this cross-compiling approach.

@senderista
Copy link
Contributor Author

Also, in gradle.properties we could set org.gradle.java.home=$JAVA7_HOME, but this still requires the user to set an environment variable for the location of their alternative JDK, so it's no less work. On the other hand, it might be more robust than specifying the boot classpath and using a newer JDK for the build--I'm not really sure. I'll try it locally and see if it works on a Java7 runtime environment (EC2).

@senderista senderista closed this May 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants