Ondrej Špeťko Ondrej Špeťko - 1 year ago 128
Java Question

Error while committing and pushing Java application from Eclipse to Openshift server (String in switch not supported)



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,


Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download