Buildr complains about javac: incorrect initial release: 1.7

I am having a problem with Apache Buildr complaining about an invalid source release. Whenever I try to create my project, I get the following error message:

javac: invalid source release: 1.7 Usage: javac <options> <source files> use -help for a list of possible options Buildr aborted! RuntimeError : Failed to compile, see errors above 

It can be assumed that I do not have Java 7 installed on my system, but when I run javac -version , I get javac 1.7.0-u10-b08 , that is, the OpenJDK that I just installed.

What's going on here? My first assumption was that Buildr was starting the wrong version of Java, but I do not know how to fix or confirm this.

To give some insight into this issue, I run Mac OS X version 8 (Mountain Lion) and installed OpenJDK from http://code.google.com/p/openjdk-osx-build/ . I use RVM to manage Ruby and install Buildr using env JAVA_HOME=$JAVA_HOME gem install buildr , as recommended in the documentation. My JAVA_HOME is installed in /Library/Java/JavaVirtualMachines/1.7.0u.jdk/Contents/Home , where I installed OpenJDK.

If anyone could help me, I would really appreciate it.

UPDATE: It seems that Buildr just does not respect my JAVA_HOME. I turned on and unchecked the Java system version (version 6) in the Java settings and now I get another error,

 JavaVM: requested Java version ((null)) not available. Using Java at "" instead. JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib JavaVM FATAL: Failed to load the jvm library. Buildr aborted! RuntimeError : can't create Java VM 
+4
source share
3 answers

I looked at this and it looks like this is a bug related to how RJB works on OSX. RJB is the library that Buildr uses to interact with the JVM. In essence, RJB does not seem to allow JVM to be configured without setting any environment variables (perhaps during build?). See http://rjb.rubyforge.org/ .

There are two main ways around this:

  • use an external compiler by adding something like "compile.using (: externaljavac)" to your build file.
  • use JRuby.

I will consider what is necessary for the correct solution of this next version (1.4.8).

Update

Fixed in 1.4.8 - the work for 1.4.7 is to set the JVM_LIB environment variable, for example

 export JVM_LIB=$JAVA_HOME/jre/lib/server/libjvm.dylib 
+6
source

This is not so much an answer as a job. I got the build to work, but only after I installed and used JRuby instead of Ruby (CRuby? I'm more of a guy from Python).

From my research, it seems that 1.7 JVMs cause a lot of problems on Mac OS X. Eclipse seems to experience a very similar problem when the platform does not start using Java Preferences and JAVA_HOME specific JVMs. I hope that at some point these problems will be solved, but at the moment it seems that JRuby is a good way to work around.

TL; DR; use JRuby.

+1
source

It looks like a build problem. Historically, we discovered a Java home folder on a Mac using a predefined path. I think this overrides JAVA_HOME. It would be nice to check this out.

If you register a bug in the Buildr bug tracking system, we can look at it.

+1
source

Source: https://habr.com/ru/post/1436196/


All Articles