'Tomee Maven Plugin Specify Java Binary

We are using the Tomee Maven Plugin for starting a Tomcat server and running some webapps. We need to use a specific version of Java, which is installed on the local system. Yet the Plugin picks the wrong Java version for starting Tomcat. We then get illegal argument exceptions due to the wrong Java version being used. How can we configure the Tomee Maven plugin to use a specific Java version?



Solution 1:[1]

Looking at the documentation there does not seem to be anyway to specify Java Version.

However each version of Tomee supports specific versions of Java, for example Java8/11, etc.

You could select the version that is suitable for your JDK version, as well ensure that your pom.xml has source/target for the specific java version you want:

   <properties>
     <tomee.version>7.0.2</tomee.version>
     <maven.compiler.target>1.8</maven.compiler.target>
     <maven.compiler.source>1.8</maven.compiler.source>
   </properties>

You could also ensure that your maven compiler plugin uses the appropriate JDK:

   <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.6.1</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>
    

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JCompetence