Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: the problem for accessing the classes in rt.jar Date: Mon, 16 Apr 2012 14:31:42 -0700 (PDT) Organization: http://groups.google.com Lines: 77 Message-ID: <16778553.2086.1334611902913.JavaMail.geo-discussion-forums@pbtr10> References: <22583724.345.1334591253848.JavaMail.geo-discussion-forums@vbvf19> NNTP-Posting-Host: 69.28.149.29 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1334612028 12329 127.0.0.1 (16 Apr 2012 21:33:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 16 Apr 2012 21:33:48 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 Xref: csiph.com comp.lang.java.programmer:13593 On Monday, April 16, 2012 10:22:09 AM UTC-7, markspace wrote: > On 4/16/2012 8:47 AM, zyng wrote: > > > > This is smart and a good idea. It shows that the classes are being > loaded, yes? > > > > The printout shows that indeed all those JAR files inside jre/lib are loaded: > > Good! > > > > However, I need this to compile successfully: > > > > This is crazy and there's no need to do this. Furthermore, rt.jar belongs in the *bootclasspath*, not the classpath, as was stated before. You never need to refer to it explicitly. Your problem lies elsewhere, OP. > > (/A/B/java is a solft link to /A/B/jdk1.6.0_25) > > This could be an issue. Please remove all links, hard and soft, and use > only one single canonical path. If /A/B on your system is /usr/lib, > use only that. If /A/B is C:\Program Files\Java, use only that. > > The Java runtime loads files according to their path names, and may > become confused if it sees the same file twice with a different path > name. I haven't had problems with it myself, but if we're hunting > obscure bugs let's eliminate all possible sources of error. > > > > To make my story short, my findings is that in order to compile, rt.jar must shows up twice and the path must be different from the first time by these observations: > > 1) this won't compile: > > > > > > > > > > > ... > > > > This make no sense. Why won't it compile? What error message do you > get? It's just a path, it shouldn't "compile" on its own unless you > have a javac tag or similar. > > > > > > This is a horrendously bad idea and can only make matters worse. I > think at this point you've messed things up so bad we can't really help > you. Remove ALL extra files from the Java installation directory that > you created, or delete the whole thing and reinstall it to be safe. > > > > (java loads rt2.jar, now my code compiles successfully) > ... > > 3)this will work(copy jre/lib to somewhere else beforehand) > > Something is really badly messed up here. > > > > Can you help me understand this? > > > Can you delete your entire Java installation and re-install it? > Then please make a very simple "Hello World" program, plus its ant build > file, and post EVERYTHING you are doing here, as well as all error > messages and program output. Here's a simple example for ant: > > Follow markspace's advice. You're doing completely the wrong thing trying to use rt.jar explicitly. Don't do that. -- Lew