Search code examples
javalinuxerror-handlingcompiler-errorsjavac

javac issues compiling source code


I'm trying to compile a Java source code with javac in a Linux terminal allocated in a machine that I have not permission to modify its Java version. Now it has 1.7.0_111 version, and the result I obtained is:

enter image description here

How can I manage to compile my code? Is there any manner to compile my source code using compatibility mode?

Thank you.


Solution

  • The code is actually compiled with JDK 8 and you want to execute it with Java 7.
    You cannot.

    If you code doesn't use specificities from Java 8, you could compile it with as Java target, the Java 7 version.

    For example :

    javac -source 1.7 -target 1.7  ...
    

    Otherwise you are stuck.