Invalid flag -parameters in java 1.7
Asked Answered
P

4

6

I have the task to create the spring-boot application using Java 7.

So, as usual, I created a template on start.spring.io resource and open him via File -> New -> Project from Existing Sources...

When I run with jdk-8, everything works fine, but when I change JDK to version 1.7 (also I change java-version in pom.xml) I get a compilation error:

Error:java: invalid flag: -parameters

Screenshot:

enter image description here

Pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.2.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.exercise</groupId>
<artifactId>quadratic</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>quadratic</name>
<description>Demo project for Spring Boot</description>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

I have no created any classes in this project.

Primogenitor answered 14/2, 2019 at 22:46 Comment(0)
T
2

Spring Boot 2.1 requires Java 8 as per the documentation:

Spring Boot 2.1.2.RELEASE requires Java 8 and is compatible up to Java 11 (included). Spring Framework 5.1.4.RELEASE or above is also required.

You must downgrade to Spring Boot 1.5 if you plan to use Java 7, as per the documentation:

Spring Boot 1.5.19.RELEASE requires Java 7 and Spring Framework 4.3.22.RELEASE or above. You can use Spring Boot with Java 6 with some additional configuration. See Section 85.11, “How to use Java 6” for more details.

Toro answered 14/2, 2019 at 22:49 Comment(0)
E
6

-parameters is new feature introduced in java 1.8. The error is expected when it is used in java 1.7.

So please update java version to 1.8 if you want this feature.

Enjoyable answered 14/2, 2019 at 23:2 Comment(0)
T
2

Spring Boot 2.1 requires Java 8 as per the documentation:

Spring Boot 2.1.2.RELEASE requires Java 8 and is compatible up to Java 11 (included). Spring Framework 5.1.4.RELEASE or above is also required.

You must downgrade to Spring Boot 1.5 if you plan to use Java 7, as per the documentation:

Spring Boot 1.5.19.RELEASE requires Java 7 and Spring Framework 4.3.22.RELEASE or above. You can use Spring Boot with Java 6 with some additional configuration. See Section 85.11, “How to use Java 6” for more details.

Toro answered 14/2, 2019 at 22:49 Comment(0)
B
1

Unsupported version of spring boot for Java 7. Pleaser downgrade and try

Berneicebernelle answered 14/2, 2019 at 22:50 Comment(0)
W
0

For me the JAVA_HOME was pointing to Java 1.7 although the java -version gave me Java 1.8 version.

So in CMD I just set the JAVA_HOME to 1.8 folder, and aligned also the PATH like

set PATH=%JAVA_HOME%\bin:%PATH%

Whistler answered 10/11, 2021 at 13:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.