Java Memorandum - How to make javac to reference user library BEFORE built-in library (rt.jar)

Here's the situation. I have a jar file, which is a library I need to use for an embedded Java application. Even though the embedded device only support Java 1.4, the library implements some 5.0 methods in org.w3c.dom.DOMImplementation. Because the same class is already in rt.jar for 1.4, just compiling a normal way doesn't work. It references the same class in rt.jar first and causes an compilation error. Here's the way to solve this...

Eclipse

There's a way to configure the order of build class path. Java Build Path --> Order and Export.

If I move up the customDOM.jar to the top, the compiler sees it first.

ANT

When building the same Java project using ANT, I needed to specify bootclasspath.

  <path id="compile.boot.path">
    <
fileset dir=".">
      <include
name="customDOM.jar" />
    </
fileset>
    <
fileset dir="${java.home}/lib">
      <include
name="rt.jar" />
    </
fileset>
  </
path>

  <
javac destdir="${build.classes.dir}"
       
debug="on"
       
deprecation="on"
       
optimize="off">
     <
bootclasspath refid="compile.boot.path" />
     <
classpath refid="compile.path" />
     <
src path="${project.src.dir}" />
     <
src path="${build.generated.dir}" />
     <include
name="**/*.java" />
  </
javac>

新しいコメントの投稿

このフィールドの内容は非公開にされ、公表されることはありません。
  • ウェブページアドレスとメールアドレスは、自動的にハイパーリンクに変換されます。
  • 使用できるHTMLタグ: <a> <em> <strong> <code> <cite> <ul> <ol> <li> <dl> <dt> <dd> <p>
  • 行と段落は自動的に折り返されます。
  • Amazon製品へのリンクを次の形式で作成することが出来ます。[amazon product_id inline|full|thumbnail]. 例: [amazon 1590597559 thumbnail]
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • 画像を追加することが出来ます。

書式オプションに関するより詳しい情報...

認証コード
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
画像で表示されている数字および記号を入力してください。