I have an application compiled in Java. I build my code through Maven. I want a tag in my project POM, so that if JRE 1.6 is not found in the system, it should not allow my Java application to launch.
Can I get any help with regard to this ?
I have an application compiled in Java. I build my code through Maven. I want a tag in my project POM, so that if JRE 1.6 is not found in the system, it should not allow my Java application to launch.
Can I get any help with regard to this ?
Perhaps you want to read this:
http://maven.apache.org/enforcer/maven-enforcer-plugin/usage.html
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>2.0.6</version>
</requireMavenVersion>
**<requireJavaVersion>
<version>1.5</version>
</requireJavaVersion>**
<requireOS>
<family>unix</family>
</requireOS>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
You can run your application as
java -version:1.6 -jar app.jar
it won't start if JRE is not 1.6
or check JRE version programmatically as
public static void main(String[] args) throws Exception {
if (!System.getProperty("java.version").startsWith("1.6")) {
throw new IllegalStateException("Illegal JRE version");
}
}