Java Mailing List Archive

http://www.ant-tasks.com/

Home » Ant Users List »

Cross-compilation problem

Christian Schröder

2008-02-22

Replies: Find Java Web Hosting

Author LoginPost Reply
Hi list,
I have some projects that should be compiled with javac 1.4 and some
that should be compiled with javac 1.5. Since I do not want to change my
environment between the projects, I have the JAVA_HOME variable set to
the 1.5 classpath and want ant to use the external 1.4 javac when
necessary. Unfortunately, I always get an "Error running
/usr/java/j2sdk1.4.2/bin/javac compiler".

I have been able to create a small example build file to reproduce this
problem:

<?xml version="1.0" encoding="UTF-8"?>
<project name="TestProject" default="default" basedir=".">
  <target name="default">
    <javac srcdir="src" destdir="classes" source="1.4" target="1.4"
fork="yes" executable="/usr/java/j2sdk1.4.2/bin/javac"/>
  </target>
</project>

With verbose output I get the following stack trace:

/home/chschroe/deriva/projects/DerivaLibLogging/build-tmp.xml:4: Error
running /usr/java/j2sdk1.4.2/bin/javac compiler
    at
org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.executeExternalCompile (DefaultCompilerAdapter.java:509)
    at
org.apache.tools.ant.taskdefs.compilers.JavacExternal.execute (JavacExternal.java:61)
    at org.apache.tools.ant.taskdefs.Javac.compile (Javac.java:997)
    at org.apache.tools.ant.taskdefs.Javac.execute (Javac.java:820)
    at
org.apache.tools.ant.UnknownElement.execute (UnknownElement.java:288)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke (Method.java:585)
    at
org.apache.tools.ant.dispatch.DispatchUtils.execute (DispatchUtils.java:105)
    at org.apache.tools.ant.Task.perform (Task.java:348)
    at org.apache.tools.ant.Target.execute (Target.java:357)
    at org.apache.tools.ant.Target.performTasks (Target.java:385)
    at
org.apache.tools.ant.Project.executeSortedTargets (Project.java:1329)
    at org.apache.tools.ant.Project.executeTarget (Project.java:1298)
    at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets (DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets (Project.java:1181)
    at org.apache.tools.ant.Main.runBuild (Main.java:698)
    at org.apache.tools.ant.Main.startAnt (Main.java:199)
    at org.apache.tools.ant.launch.Launcher.run (Launcher.java:257)
    at org.apache.tools.ant.launch.Launcher.main (Launcher.java:104)
Caused by: java.io.IOException: java.io.IOException: Cannot allocate memory
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
    at java.lang.ProcessImpl.start (ProcessImpl.java:65)
    at java.lang.ProcessBuilder.start (ProcessBuilder.java:451)
    at java.lang.Runtime.exec (Runtime.java:591)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke (Method.java:585)
    at
org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.java:828)
    at org.apache.tools.ant.taskdefs.Execute.launch (Execute.java:445)
    at org.apache.tools.ant.taskdefs.Execute.execute (Execute.java:459)
    at
org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.executeExternalCompile (DefaultCompilerAdapter.java:506)
    ... 20 more

The machine has several gigs of free memory and this test project is
really small. So what's the problem?

Some information about my environment:

Apache Ant version 1.7.0 compiled on December 13 2006
javac 1.5.0_12
javac 1.4.2_15

Thanks for all help!
  Christian

--
Deriva GmbH                 Tel.: +49 551 489500-42
Financial IT and Consulting      Fax: +49 551 489500-91
Hans-Böckler-Straße 2            http://www.deriva.de
D-37079 Göttingen

Deriva CA Certificate: http://www.deriva.de/deriva-ca.cer


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.