Gangmax Blog

我今天遇到的和ANT+JDK相关的编译问题

今天我用RTC编译整个工程遇到了几个问题。

我遇到的第一个问题是用Ant编译Dependencies工程报错。错误信息大概意思是启动javac失败。

解决的方法是:在”Windows -> Pereferences -> Ant -> Runtime -> Global Entries”里面,确保使用的tools.jar属于Eclipse使用的JDK。

我遇到第二个问题是编译”build -> build alpine only” target时,得到以下错误:

1
2
3
Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.

解决方法来自这里:安装”openjdk-6-jdk”:

1
sudo apt-get install openjdk-6-jdk

这两个问题的共同特点是和JDK的设置有关,要避免此问题,需要保证以下JDK设置统一:

  1. JAVA_HOME environment variable;

  2. The “-vm” parameter in the Eclipse(RTC) “eclipse.ini” file;

  3. “tools.jar” configuration of “Windows -> Pereferences -> Ant -> Runtime -> Global Entries” should be unique and be as the same as the other JDK configuration;

  4. In the “Run as… -> Ant Build…” configuration, use “Run in the same JRE as the workspace” in the “JRE” tab;

  5. Eclipse default JRE: “Windows -> Pereferences -> Java -> Installed JREs”.

注意:

如果在以上设置中使用了Ubuntu默认的”OpenJDK”或者官方的”SUN JDK”,则使用Ant编译的过程中会出现编译错误,这意味着以上的JDK配置只能使用”IBM JDK”来进行编译。

Added@20120626:

当编译”build->build(default)”时,其中的”build.depends/build.pydoc.xml”会使用到”python”可执行文件的内容。默认是从”build.depends/build.properties”文件去取得,不过麻烦的是这个文件是动态生成的,我也没有花时间去研究它是何时由谁生成的。简单的修改办法就是直接修改”build.pydoc.xml”中所有的如下内容:

1
2
3
4
5
<exec executable="${python.cmd}" ...>

<!-- From above to below, replace it with your python executable file. -->

<exec executable="/usr/bin/python2.7" ...>

“[eclipse.buildScript] Missing required plug-in com.ibm.ant.launching_0.0.0.” error solution:

First, get a recent Eclipse install package, such as 3.7.2(in my case), go to its “plugins” directory and copy the following jar files to the RTC “client/eclipse/plugins” directory:

  • org.eclipse.ant.launching_1.0.101.v20120110-1739.jar

  • org.eclipse.debug.core_3.7.1.v20111129-2031.jar

  • org.eclipse.core.externaltools_1.0.100.v20111007_r372.jar

And run the ant build again, the problem should be resolved.

Added@20120703:

Today I get a new branch(3.1.0.3) to local and here is the build process(incredible simple, that may be caused by the same RTC environment, so I don’t do the ant/JDK configuration anymore).

  • Get the branch code and load it in a new workspace;

  • Find “public*.xml” ant files in the Ant view;

  • Run “Dependencies/get” target(Same JRE as workspace);

  • Build “Build/build alpine only” target(Same JRE as workspace);

  • Build “Build/build(default)” target(Same JRE as workspace).

Comments