0

I converted an old Java 1.8 project to a Maven project in Eclipse, but it is still giving me weird errors such as '<>' operator is not allowed for source level below 1.7.

How is this possible when I only have java 1.8 installed, Eclipse JDK-compliance is 1.8 and in build path: Workspace default JRE is jdk1.8.0_202?

java -version gives:

java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)

Also, I did mvn eclipse:eclipse after the convert but it does not find the Main-class when I try to "run as Java Application"

Now I've tried mvn clean install and mvn eclipse:clean, but they don't help.

My pom.xml file:

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>myApplication</groupId>
    <artifactId>myApplication</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>myApplication</name>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>org.my.Application.main.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
        <dependency>
            <groupId>com.oracle.ojdbc</groupId>
            <artifactId>ojdbc8</artifactId>
            <version>19.3.0.0</version>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>

        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.8.5</version>
        </dependency>

        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-core-lgpl</artifactId>
            <version>1.8.5</version>
        </dependency>

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.1</version>
        </dependency>
    </dependencies>
</project>

As an amateur programmer, I've noticed that configuring Maven or Gradle are the hardest things to do.

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
willberthos
  • 305
  • 1
  • 4
  • 15
  • 2
    You need to set `maven.compiler.source` and `maven.compiler.target` as [documented here](https://www.baeldung.com/maven-java-version). – Joachim Sauer Nov 16 '21 at 11:07
  • @JoachimSauer this did help with the 1.7 problem, but after a new "mvn eclipse:eclipse" the Run as a Java Application can not find the main class still. – willberthos Nov 16 '21 at 12:06

0 Answers0