0

BUILD FAILURE

Hi,

I successfully set up everything to apply changes to my application located on Openshift server. Suddenly I decided to use some of my Java classes from other project and when I try to commit changes I get this error.

I am really hopeless with the error as I was researching for about a day and google just go blank on me with this and related questions. The problem is that I can't figure out what the "-source 7" stands for and if it related to the "-source 1.6" that is mentioned in the line above it in the error message.

Error message:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-   plugin:2.3.2:compile (default-compile) on project organizer: Compilation failure: Compilation failure:
[ERROR] /var/lib/openshift/56c42c687628e1f0a2000073/app-root/runtime/repo/src/main/java/organizer/DataOperations.java:[185,9] error: strings in switch are not supported in -source 1.6
[ERROR] (use -source 7 or higher to enable strings in switch)

This error is repeated for every instance of using String in switch statement.

EDIT: I am looking for a solution not only explanation. Trying to configure pom file atm.

I appreciate any help at all..

Thank you,

Ondrej

3
  • Java versions before Java 7 didn't support String in switch statements; using -source 1.6 tells the compiler to compile the code as though it is Java 6 (or Java 1.6) code, which doesn't support switch for String, hence the build failure May 5, 2016 at 19:52
  • I could have guessed that but I had no idea how to fix it. I am trying the solution below atm. Thanks for the clarifying comment though.
    – shourikan
    May 7, 2016 at 11:31
  • I just realized my question is not clearly stated as I search for solution and not only explanation.
    – shourikan
    May 7, 2016 at 11:33

1 Answer 1

1

As noted above, String in Switch statements are only supported in Java 7+.

Looking at the error message you should update your POM to include the following i.e. explicitly compile against Java 7.

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>7</source>
                    <target>7</target>
                </configuration>
            </plugin>
        </plugins?
    </pluginManagement>
<build>
1
  • This solution worked perfectly. Pom.xml contained the source info and changing compiler source to 1.7 solved the issue. Build successful. Thanks!
    – shourikan
    May 7, 2016 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.