I just upgraded from Java 6 to Java 7 and now my gradle script can’t find rt.jar. Can anyone tell me why my gradle script complains that it can’t find rt.jar when referencing jdk1.7.0_40/jre/lib? But when I change it back to jdk1.6.0_37/jre/lib it finds it just fine? Or when I make a soft link to jdk1.7.0_40/jre/lib and reference the soft link it works too.
Here is where I am referencing it in my script when it doesn’t work:
It seems to me that that something is somehow excluding the rt.jar under /opt/jdk1.7.0_40/jre/lib when I have “jdk1.7.0_40” specified in the path. That really seems weird.
Any ideas? I would love to remove the bandaid of using a soft link.
or are you looking for the dependency in the code?
Here are the errors I get when specifying jdk1.7.0_40/jre/lib:
/var/lib/jenkins/jobs/someProject/src/captchas/JCaptchaImage.java:52: error: cannot find symbol
JPEGImageEncoder jpegEncoder =
^
symbol:
class JPEGImageEncoder
location: class JCaptchaImage
/var/lib/jenkins/jobs/someProject/src/captchas/JCaptchaImage.java:53: error: cannot find symbol
JPEGCodec.createJPEGEncoder(jpegOutputStream);
^
symbol:
variable JPEGCodec
location: class JCaptchaImage
/var/lib/jenkins/jobs/someProject/src/captchas/JCaptchaImage.java:5: error: package com.sun.image.codec.jpeg does not exist
import com.sun.image.codec.jpeg.JPEGCodec;
^
/var/lib/jenkins/jobs/someProject/src/captchas/JCaptchaImage.java:6: error: package com.sun.image.codec.jpeg does not exist
import com.sun.image.codec.jpeg.JPEGImageEncoder;
Here is what I get when I don’t include the jre/lib at all:
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':someProject:compile'.
> Could not find group:, module:rt, version:.
I have no idea why this would happen. What happens if you add an explicit file dependency instead? E.g. ‘compile files("/opt/jdk1.7.0_40/jre/lib/rt.jar")’.
My best (and wild) guess is that the Java compiler tries to prevent ‘rt.jar’ from being put on its compile class path. Ultimately, your question is about how to compile against an internal JDK API. Maybe this related Stack Overflow discussion will help you get further: http://stackoverflow.com/questions/19124873/sun-jpegimageencoder-compilation-in-gradle