0

I have a piece of code which has been compiled with java version 1.5 ( both source and target are set to 1.5 on maven compile plugin )

<source>1.5</source>
<target>1.5</target>

What I want to do now is to compile them for an application ( the source is a plug in for a main application )which is upgraded to java version 1.6

In this case;

do I need to use compile plugin with the parameters;

<source>1.5</source>
<target>1.6</target>

or

<source>1.6</source>
<target>1.6</target>

plus; do I need to set the java home and path to java 1.6 or plugin will use the correct artifacts ( may be by downloading ) to compile for java 1.6 ??

regards..

2
  • do you realize that sources compiled for 1.5 will work just fine on java 1.6? Commented Dec 11, 2011 at 11:56
  • there are some interface changes in the plugin fw. so that I want to compile it with 1.6 would there be a problem by using; <source>1.5</source> <target>1.6</target> Commented Dec 11, 2011 at 12:08

3 Answers 3

1

First of all, you don't absolutely have to recompile on Java 1.6. Your Maven artifacts compiled using Java 1.5 will probably work fine when used by a Java 1.6 application running on a Java 1.6 platform.

If you do want to recompile, then either combination should work. In fact, they are for all intents and purposes identical since there were no relevant changes in the language between Java 1.5 and 1.6. However, there is value in compiling and running the unit tests on Java 1.6 ... just in case some library change causes your code to fail on the newer platform.

Sign up to request clarification or add additional context in comments.

1 Comment

thank you very much Stephan. I think I will use 1.6;1.6 combination and check for the errors. regards..
0

You should use the Java 1.6 in your JAVA_HOME and your plugin should run if you use target/source with 1.5 this should run with 1.6. Except if you are using particular things from Java 1.6 (String.isEmpty() for example)...

Comments

0

Always set source and target in your pom.xml file

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.