iyuichiの私的開発ログ

渋谷で働くWebエンジニアのログ. Java, Android, iOS, Docker, GCP, AWS, ゲーム開発

Sun が所有する APIに悩まされた

eclipseでは何の問題もなくコンパイルされているソースが、mavenでビルドするとBUILD FAILUREとなる現象にちょっとはまりました。

こんな警告が出ます。
「○○ は Sun が所有する API であり、今後のリリースで削除される可能性があります。」

jdk5を使っているときは特になんの問題もなくビルドできていたのですが、jdk6にしてみようとしたら。。でした。

で、結果としてはrt.jarを明示的にコンパイル時のbootclasspathに設定してやったらビルドができるようになりました。

Now your code is relying on a Sun internal class and not a base JDK class. The appropriate classes exist in the $JAVA_HOME/lib/rt.jar file. Unfortunately, this jar file is NOT used by default when running javac. So to get my code to compile, I had to use the rt.jar in my bootclasspath. Since I am using Maven 2.0 as my build system, I had to add the following to the pom.xml where I am defining my compiler

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<verbose />
<bootclasspath>${java.home}/lib/rt.jar</bootclasspath>
</compilerArguments>
</configuration>
</plugin>

結構、情報を探したのでメモ。
# mavenってはまると情報が少なくていつも大変。。