Java Memorandum - How to make javac to reference user library BEFORE built-in library (rt.jar)
投稿者:Nobu 投稿日時:2010/07/07(水) 15:59
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>

新しいコメントの投稿