X-Received: by 10.224.131.193 with SMTP id y1mr4044748qas.8.1363806880208; Wed, 20 Mar 2013 12:14:40 -0700 (PDT) X-Received: by 10.50.40.103 with SMTP id w7mr44964igk.11.1363806880160; Wed, 20 Mar 2013 12:14:40 -0700 (PDT) Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!dd2no4050414qab.0!news-out.google.com!k8ni4137qas.0!nntp.google.com!dd2no4050412qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Wed, 20 Mar 2013 12:14:39 -0700 (PDT) In-Reply-To: <3ef61613-19c4-42d5-a9bb-82c2d9b4b8cd@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T NNTP-Posting-Host: 69.28.149.29 References: <3ef61613-19c4-42d5-a9bb-82c2d9b4b8cd@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <4ccc8333-ce6f-41ab-ab37-dc45c6d93a80@googlegroups.com> Subject: Re: help: class conflict in two different version JAR files From: Lew Injection-Date: Wed, 20 Mar 2013 19:14:40 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Received-Bytes: 2907 Xref: csiph.com comp.lang.java.programmer:22987 zyng wrote: > I am using Eclipse. Project A uses 3rdparty.1.0.1.jar file; Project B uses 3rdparty.1.0.3.jar file. > Project B depends on Project A. Advice #1: Build your project using Ant and command-line tools. That will help you understand what Eclipse is doing. > I am working on Project B. I am not supposed to change anything in Project A. I hope that the code in Ideally Project A will come to Project B as a JAR, e.g., "projectA.jar". > B always use the class inside 3rdparty.1.0.3.jar. I don't know how to do that. I found that for the This is not really the way to look at it. One moment ... > classes in 3rdpartyxx.jar, the code in B just use the class in 3rdparty.1.0.1.jar file, which is used by A. That is because both JARs are in your classpath. >I guess since B depends on A, so 3rdparty.1.0.1.jar file has the higher priority. That is not correct. It is because "3rdparty.1.0.1.jar" is ahead of "3rdparty.1.0.3.jar" in the classpath. Just remove "3rdparty.1.0.1.jar" from the classpath. > This causes some problem, which I just omit here. Problems that the Project B cannot compile because it uses a newer version of "3rdparty". But of course. Unless "3rdparty" really screwed up backwards compatibility, remove the old version from the classpath. Otherwise, put Project A after "3rdparty.1.0.3.jar" in your classpath for Project B. > If running by ANT on the command line, due to the way I set up(project A's code listed near the end > of the Java classpath), the code in B uses the classes in 3rdparty.1.0.3.jar and the problem was avoided. Read up on classpaths. > I hope to solve the problem in Eclipse. Thank you for your help. Have Eclipse use the Ant build.xml. -- Lew