maidh91 / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

build.xml cannot find rt.jar on Mac OS X #327

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Trying to build Guava on my Mac OS X 10.6 system using the following
command fails because Apple doesn't have an explicit rt.jar in it's
1.5 home directory.

$ JAVA5_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home ant
Buildfile: build.xml

compile:
    [mkdir] Created dir: /Users/blair/Code/Sony/google-guava.git/build/classes

BUILD FAILED
/Users/blair/Code/Sony/google-guava.git/build.xml:17: JAVA5_HOME must be set to 
a valid JDK 
1.5 installation, containing a jre/lib/rt.jar file

Original issue reported on code.google.com by blair-ol...@orcaware.com on 20 Feb 2010 at 6:04

GoogleCodeExporter commented 9 years ago
There is a good tip about how to fix such problem on Mac OS 
http://blogs.sun.com/bobby/entry/tip_installing_jdeveloper_on_mac

Also it can be fixed by adding more rules to build file.
The only thing I don't understand is - why it requires exactly java 1.5 
version. 
Maybe it would be better to do something like this?
   <condition property="isJavaHomeSetRight">
      <and>
        <or>
          <equals arg1="${java.specification.version}" arg2="1.5" />
          <equals arg1="${java.specification.version}" arg2="1.6" />
        </or>
        /* task to check rt.jar */
      </and>
    </condition>

Original comment by ruhe....@gmail.com on 28 Feb 2010 at 1:41

GoogleCodeExporter commented 9 years ago
Step 1:
Update the problem line in your build.xml to:
<property name="java5bootclasspath" 
value="${env.JAVA5_HOME}/Classes/classes.jar"/>

Step 2:
you$ export JAVA5_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5

Step 3:
you$ ant compile

Will make a blog entry with more detail ria101.wordpress.com

Original comment by home.mel...@gmail.com on 17 Mar 2010 at 1:44

GoogleCodeExporter commented 9 years ago
I had equal luck simply removing the bootclasspath="${java5bootclasspath}" 
attribute from the javac directive. 
That worked for me with the default Java 1.5 installation on OS X Leopard. I'm 
not quite sure why build.xml is 
structured to require JAVA5_HOME to be set.

Original comment by jacobly@google.com on 29 Mar 2010 at 3:57

GoogleCodeExporter commented 9 years ago
I trust this issue should become moot once we're providing you with a binary 
JAR you 
can just use?

Original comment by kevinb@google.com on 30 Mar 2010 at 12:07

GoogleCodeExporter commented 9 years ago
Maybe, sometimes I like to build new jars off of an unreleased svn revision 
(say you want a jar with a bug fix or 
some new feature), so it would be nice to generally leave the capability there 
to build a jar at any time.

Original comment by blair-ol...@orcaware.com on 30 Mar 2010 at 3:33

GoogleCodeExporter commented 9 years ago
This is a must have fix...

Original comment by terciofi...@gmail.com on 11 Apr 2010 at 3:52

GoogleCodeExporter commented 9 years ago
If someone wants to send a build.xml patch to allow -DpathToRtJar, which would 
default 
to the current location if not set, that would be fine.

Original comment by kevinb@google.com on 23 Apr 2010 at 8:34

GoogleCodeExporter commented 9 years ago
Here's a patch for build.xml to support Apple's JDK layout in addition to the
standard Sun/Oracle/OpenJDK layout. Unfortunately on OS X 10.6+, there is no 
actual
JDK 5 as it is actually just a symlink to JDK 6, so this doesn't give the same
guarantees of JDK5 API compatibility desired by using the javac bootclasspath. 
I've
included some examples of building on Mac OS X 10.6.3 with Apple's 1.6.0_17 as 
well
as building with soylatte JDK 6 1.6.0_03-p3-landonf_19_aug_2008_14_55-b00. I 
haven't
tested this on other platforms, but I believe it should work.

You can either set JAVA5_HOME to
/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/ and it will use
/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Classes/classes.jar 
for the
bootclasspath, or you can pass the bootclasspath explicitly
-Djava5bootclasspath=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Cl
asses/classes.jar
to ant.

The guava sources do appear to use Java 6 specific features such as @Override 
for
interface implementations, so it seems the assumption is that the JDK version 
used to
run Ant's javac must be JDK 6; however, the actual desired binary compatibility 
is
for JDK 5.

Thanks for guava and collections. Hope this helps someone else out.

Apple Mac OS X 10.6+ Java versions:
$ ls -ahlF /System/Library/Frameworks/JavaVM.framework/Versions/1.5
lrwxr-xr-x 1 root wheel 10 Dec  4 18:31
/System/Library/Frameworks/JavaVM.framework/Versions/1.5 -> CurrentJDK/

$ ls -ahlF /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
lrwxr-xr-x 1 root wheel 3 Dec  4 18:31
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK -> 1.6/

$ ls -ahlF /System/Library/Frameworks/JavaVM.framework/Versions/1.6
lrwxr-xr-x 1 root wheel 5 Dec  4 18:31
/System/Library/Frameworks/JavaVM.framework/Versions/1.6 -> 1.6.0/

$ ls -ahlF /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0
total 0
drwxr-xr-x  8 root            wheel  272 Mar 23 08:23 ./
drwxr-xr-x 13 root            wheel  442 Dec  4 18:32 ../
drwxr-xr-x 12 root            wheel  408 Dec  4 18:31 Classes/
drwxr-xr-x 41 root            wheel 1.4K Dec  4 18:31 Commands/
drwxr-xr-x 12 root            wheel  408 Jan 29 23:04 Headers/
drwxr-xr-x 11 root            wheel  374 Dec  4 18:31 Home/
drwxr-xr-x 48 _update_sharing wheel 1.6K Dec  4 18:31 Libraries/
drwxr-xr-x 23 root            wheel  782 Dec  4 18:31 Resources/

--------------------------------------------------------------------------------
$ JAVA5_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home/ ant 
clean
compile
Buildfile: build.xml

clean:
   [delete] Deleting directory /Users/david/Documents/dev/guava/build

compile:
    [mkdir] Created dir: /Users/david/Documents/dev/guava/build/classes
     [echo] Using java5bootclasspath:
/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Classes/classes.jar
    [javac] Compiling 220 source files to /Users/david/Documents/dev/guava/build/classes

BUILD SUCCESSFUL
Total time: 8 seconds
--------------------------------------------------------------------------------
$ JAVA5_HOME=/Users/david/Documents/dev/jdk/soylatte16-i386-1.0.3 ant clean 
compile
Buildfile: build.xml

clean:
   [delete] Deleting directory /Users/david/Documents/dev/guava/build

compile:
    [mkdir] Created dir: /Users/david/Documents/dev/guava/build/classes
     [echo] Using java5bootclasspath:
/Users/david/Documents/dev/jdk/soylatte16-i386-1.0.3/jre/lib/rt.jar
    [javac] Compiling 220 source files to /Users/david/Documents/dev/guava/build/classes

BUILD SUCCESSFUL
Total time: 9 seconds
--------------------------------------------------------------------------------
$ ant
-Djava5bootclasspath=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Cl
asses/classes.jar
clean compile
Buildfile: build.xml

clean:
   [delete] Deleting directory /Users/david/Documents/dev/guava/build

compile:
    [mkdir] Created dir: /Users/david/Documents/dev/guava/build/classes
     [echo] Using java5bootclasspath:
/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Classes/classes.jar
    [javac] Compiling 220 source files to /Users/david/Documents/dev/guava/build/classes

BUILD SUCCESSFUL
Total time: 8 seconds
--------------------------------------------------------------------------------
$ ant -Djava5bootclasspath=bad.jar clean compile 
Buildfile: build.xml

clean:
   [delete] Deleting directory /Users/david/Documents/dev/guava/build

compile:
    [mkdir] Created dir: /Users/david/Documents/dev/guava/build/classes

BUILD FAILED
/Users/david/Documents/dev/guava/build.xml:43: JAVA5_HOME must be set to a 
valid JDK
1.5 installation, containing a jre/lib/rt.jar file

Total time: 0 seconds
--------------------------------------------------------------------------------

Original comment by schlo...@gmail.com on 1 May 2010 at 3:00

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 27 Jan 2011 at 2:05

GoogleCodeExporter commented 9 years ago

Original comment by fry@google.com on 28 Jan 2011 at 3:58

GoogleCodeExporter commented 9 years ago
D'oh -- I fixed this a long time ago and never told anyone.

-Djava5bootclasspath=/full/path/to/that.jar

Original comment by kevin...@gmail.com on 28 Jan 2011 at 9:04

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:15

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:10