Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: zyng Newsgroups: comp.lang.java.programmer Subject: the problem for accessing the classes in rt.jar Date: Mon, 16 Apr 2012 08:47:33 -0700 (PDT) Organization: http://groups.google.com Lines: 95 Message-ID: <22583724.345.1334591253848.JavaMail.geo-discussion-forums@vbvf19> NNTP-Posting-Host: 205.156.36.56 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1334593585 13755 127.0.0.1 (16 Apr 2012 16:26:25 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 16 Apr 2012 16:26:25 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=205.156.36.56; posting-account=oo44OQoAAABMDvaRlaO3SeQ5MVbxqLdH User-Agent: G2/1.0 Xref: csiph.com comp.lang.java.programmer:13580 Hi, I have asked the similar question before. Thank you for all your help. The = issue is still not solved and is very mysterious. By many testing, I have o= btained new observations. I think I can ask this question in a better way. = Thank you for your help. As everybody knows, rt.jar is located in jre/lib/ directory. It is *automat= ically* loaded into Java runtime platform. My code uses some classes in rt.= jar. (Whether this is wise or not, this is different issue. Here, I just ho= pe to solve the classpath issue related to rt.jar.) To check rt.jar is *automatically* loaded by Java, in ant script compile ta= rget, I added the option "-verbose". This shows all path of the classes ref= erenced: The printout shows that indeed all those JAR files inside jre/lib are loade= d: [javac] [search path for class files: /A/B/jdk1.6.0_25/jre/lib/resources.j= ar,/A/B/jdk1.6.0_25/jre/lib/rt.jar,/A/B/jdk1.6.0_25/jre/lib/sunrsasign.jar = .. However, I need this to compile successfully: ... The print out shows [javac] [search path for class files: /A/B/jdk1.6.0_25/jre/lib/resources.j= ar,/A/B/jdk1.6.0_25/jre/lib/rt.jar,/A/B/jdk1.6.0_25/jre/lib/sunrsasign.jar = .., ...,/A/B/java/jre/lib/rt.jar, .. (/A/B/java is a solft link to /A/B/jdk1.6.0_25) To make my story short, my findings is that in order to compile, rt.jar mus= t shows up twice and the path must be different from the first time by thes= e observations: 1) this won't compile: ... [javac] [search path for class files: /A/B/jdk1.6.0_25/jre/lib/resources.j= ar,/A/B/jdk1.6.0_25/jre/lib/rt.jar,/A/B/jdk1.6.0_25/jre/lib/sunrsasign.jar = .., ...,/A/B/jdk1.6.0_25/jre/lib/rt.jar, .. (the second time rt.jar path is exactly same as the first time, it seems ja= va didn't bother to re-load rt.jar -- my understanding) 2)this will work(copy rt.jar to rt2.jar before hand): ... [javac] [search path for class files: /A/B/jdk1.6.0_25/jre/lib/resources.j= ar,/A/B/jdk1.6.0_25/jre/lib/rt.jar,/A/B/jdk1.6.0_25/jre/lib/sunrsasign.jar = .., ...,/A/B/jdk1.6.0_25/jre/lib/rt2.jar, .. (java loads rt2.jar, now my code compiles successfully) 3)this will work(copy jre/lib to somewhere else beforehand) ... [javac] [search path for class files: /A/B/jdk1.6.0_25/jre/lib/resources.j= ar,/A/B/jdk1.6.0_25/jre/lib/rt.jar,/A/B/jdk1.6.0_25/jre/lib/sunrsasign.jar = .., ...,/X/Y/jre/lib/rt.jar, .. (again, the path of the second time referencing rt.jar is different, java t= hen load rt.jar into the platform and my code compiles successfully) My feeling is that the first time rt.jar loaded, the classes inside rt.jar = cannot be accessed by my code. The second time referencing rt.jar, if every= thing is exactly same as the first reference(including path and the file na= me), java skips the loading; if there is some difference(different path or = different file name) comparing to the first reference, java loads this JAR = into the platform, then my code can compile. Can you help me understand this? I really hope that in the ant script, rt.j= ar no need to be referenced. Thank you very much.=20