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: Re: the problem for accessing the classes in rt.jar Date: Wed, 18 Apr 2012 06:13:36 -0700 (PDT) Organization: http://groups.google.com Lines: 153 Message-ID: <14699406.1250.1334754816127.JavaMail.geo-discussion-forums@vbyj26> References: <22583724.345.1334591253848.JavaMail.geo-discussion-forums@vbvf19> <4f8e0210$0$290$14726298@news.sunsite.dk> 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 1334755268 14142 127.0.0.1 (18 Apr 2012 13:21:08 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 18 Apr 2012 13:21:08 +0000 (UTC) In-Reply-To: <4f8e0210$0$290$14726298@news.sunsite.dk> 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:13634 OK. And also re-phrase my question:=20 A)in build.xml file, when not including rt.jar by commenting out rt.jar: =20 I got these error message compile: [javac] C:\my_work\build.xml:47: warning: 'includeantruntime' was not s= et, defaulting to build.sysclasspath=3Dlast; set to fals for repeatable builds [javac] Compiling 407 source files to C:\my_work\build [javac] C:\my_work\src\abc\efg\xml\MyXmlUtils.java:27: package com.sun.= xml.internal.fastinfoset.stax does not exist [javac] import com.sun.xml.internal.fastinfoset.stax.StAXDocumentParser= ; [javac] ^ [javac] C:\my_work\src\abc\efg\xml\MyXmlUtils.java:28: package com.sun.= xml.internal.fastinfoset.stax does not exist [javac] import com.sun.xml.internal.fastinfoset.stax.StAXDocumentSerial= izer; [javac] ^ [javac] C:\my_work\src\abc\efg\xml\MyXmlUtils.java:29: package com.sun.= xml.internal.txw2.output does not exist ... Those packages are located inside rt.jar. And everybody agrees, rt.jar is a= utomatically loaded into the platform. Since I added the option "-verbose" = in javac, I saw this print out, which clearly shows rt.jar is in the class = path: [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 = ..=20 Clearly, my code cannot access /jre/lib/rt.jar so compiling failed. Why my = code cannot access rt.jar? B)If including rt.jar in the project.classpath: =20 I got exactly the same error message. The classpath shown by -verbose is: [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 .. "/A/B/jdk1.6.0_25/jre/lib/rt.jar" shows up twice, which makes sense(one is = due to automatically loaded, one is due to explicit reference in my build.x= ml).=20 C)if I make a soft link which points to /A/B/jdk1.6.0_25, with a name, say,= "/fs/soft_link" and in project.classpath: =20 On linux, this will work, because linux does not "translate" the soft link = back to its original path: [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 = .. /fs/soft_link/jre/lib/rt.jar .. "rt.jar" shows up twice, with different path. JAVA clearly re-loaded rt.jar= , from /fs/soft_link path and my code now can grap the classes they need. On PC, it does not work. Somehow, PC "translate" the soft link into its rea= l path, so again, "/A/B/jdk1.6.0_25/jre/lib/rt.jar" shows up twice. My gues= s is that JAVA does not do repeated loading. As case A) above showed, the f= irst time loading of "/A/B/jdk1.6.0_25/jre/lib/rt.jar" does not help my cod= e. D)this case works on both Linux and PC. Just for testing purpose only: within /A/B/jdk1.6.0_25/jre/lib/, copy rt.jar to rt2.jar, in project.classp= ath: =20 Now compiling is fine. [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 .. Clearly, JAVA loaded rt2.jar since "/A/B/jdk1.6.0_25/jre/lib/rt2.jar" looks= different from "/A/B/jdk1.6.0_25/jre/lib/rt.jar", at least in JAVA's view.= Now my code have their classes to grab. E)Needless to say, if copying rt.jar from /A/B/jdk1.6.0_25/jre/lib/ to some= where else, say, /C/D/jre/lib, now in project.classpath: =20 Compiling is fine. [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 = .. /C/D/jre/lib/rt.jar .. To summarize what I saw,=20 1)"/A/B/jdk1.6.0_25/jre/lib/rt.jar" will be loaded automatically regardless= of including rt.jar in the project.classpath or not. However, this loading= do not serve my code. 2)in build.xml, project.classpath, when referencing "rt.jar", it needs eith= er the path be different or the file name be different, somehow fool JAVA t= o really re-load this JAR file. Only this second loading of rt.jar can help= my code. Very strange! Thank you very much. Thank you very much.