Showing posts with label Maven. Show all posts
Showing posts with label Maven. Show all posts

Wednesday, November 29, 2017

specify the Java compiler version in pom.xml

For example, if you want to use the Java 8 language features (-source 1.8) and also want the compiled classes to be compatible with JVM 1.8 (-target 1.8), you can either add the two following properties, which are the default property names for the plugin parameters:
  1. <project>
  2. [...]
  3. <properties>
  4. <maven.compiler.source>1.8</maven.compiler.source>
  5. <maven.compiler.target>1.8</maven.compiler.target>
  6. </properties>
  7. [...]
  8. </project>
or configure the plugin directly:
  1. <project>
  2. [...]
  3. <build>
  4. [...]
  5. <plugins>
  6. <plugin>
  7. <groupId>org.apache.maven.plugins</groupId>
  8. <artifactId>maven-compiler-plugin</artifactId>
  9. <version>3.7.0</version>
  10. <configuration>
  11. <source>1.8</source>
  12. <target>1.8</target>
  13. </configuration>
  14. </plugin>
  15. </plugins>
  16. [...]
  17. </build>
  18. [...]
  19. </project>
@reference_1_stackoverflow.com
How do you specify the Java compiler version in a pom.xml file?
@reference_2_stackoverflow.com
Specifying java version in maven - differences between properties and compiler plugin
@reference_3_maven.apache.org
Setting the -source and -target of the Java Compiler

Saturday, November 18, 2017

Can't execute jar- file: “no main manifest attribute”

For Maven, something like the following snippet should do the trick. Note that this is only the plugin definition, not the full pom.xml:
<build>
  <plugins>
    <plugin>
      <!-- Build an executable JAR -->
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <version>3.0.2</version>
      <configuration>
        <archive>
          <manifest>
            <addClasspath>true</addClasspath>
            <classpathPrefix>lib/</classpathPrefix>
            <mainClass>com.mypackage.MyClass</mainClass>
          </manifest>
        </archive>
      </configuration>
    </plugin>
  </plugins>
</build>

@reference_1_stackoverflow.com

Eclipse/Maven error: “No compiler is provided in this environment”

Go to Window → Preferences → Java → Installed JREs.
And see if there is an entry pointing to your JDK path, and if not, click on Edit button and put the path you configured your JAVA_HOME environment.