You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mang Jun Lau <Ma...@otpp.com> on 2006/03/28 00:28:04 UTC

[M2] Compiling with JDK 1.4

Hi,

I've searched and tried the methods given before but things haven't been 
working for me.  My JAVA_HOME points to the 1.5 JDK.  I would like to 
compile my code to be able to run under JDK 1.4.  So, in my master POM, I 
have:

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <compilerVersion>1.4</compilerVersion>
          <source>1.4</source>
          <target>1.4</target>
        </configuration>
      </plugin>
    </plugins>
</build>

I've tried different permutations of the <compilerVersion>, <source>, and 
<target> tags being present and not, all to no avail.  The code compiles 
in all instances but when I execute the code, I get the exception:

java.lang.NoSuchMethodError: java.math.BigDecimal: method <init>(I)V not 
found

I googled this and I know it's because the 1.5 API has a new "int" 
constructor.  This means that my code is still being compiled with the 1.5 
JDK.  How can I get Maven to compile with the 1.4 JDK?  I've even tried 
setting the <executable> tag to point to the 1.4 javac.  The only way it 
works is if I point my JAVA_HOME to the 1.4 JDK, which I can't do because 
there are other applications that need to be compiled with 1.5 on the same 
machine.

Hope someone has done this successfully before.  Thanks.


_Mang Lau

RE: [M2] Compiling with JDK 1.4

Posted by Anthony Kong <an...@bisinfo.com.au>.
Try 'maven clean'  first then recompile.

Somehow if the class files exist in target dir, the compiler may not
overwrite them. These class files may have been compiled in 1.5 prior to
your changes to pom.xml

Cheers,
AK

-----Original Message-----
From: Mang Jun Lau [mailto:Mang_Lau@otpp.com] 
Sent: Tuesday, 28 March 2006 8:28 AM
To: users@maven.apache.org
Subject: [M2] Compiling with JDK 1.4

Hi,

I've searched and tried the methods given before but things haven't been
working for me.  My JAVA_HOME points to the 1.5 JDK.  I would like to
compile my code to be able to run under JDK 1.4.  So, in my master POM, I
have:

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <compilerVersion>1.4</compilerVersion>
          <source>1.4</source>
          <target>1.4</target>
        </configuration>
      </plugin>
    </plugins>
</build>

I've tried different permutations of the <compilerVersion>, <source>, and
<target> tags being present and not, all to no avail.  The code compiles in
all instances but when I execute the code, I get the exception:

java.lang.NoSuchMethodError: java.math.BigDecimal: method <init>(I)V not
found

I googled this and I know it's because the 1.5 API has a new "int" 
constructor.  This means that my code is still being compiled with the 1.5
JDK.  How can I get Maven to compile with the 1.4 JDK?  I've even tried
setting the <executable> tag to point to the 1.4 javac.  The only way it
works is if I point my JAVA_HOME to the 1.4 JDK, which I can't do because
there are other applications that need to be compiled with 1.5 on the same
machine.

Hope someone has done this successfully before.  Thanks.


_Mang Lau


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org