0

i have a project to run in jre 1.7. however, i have jre 1.8 installed on my machine and is configured on Eclipse.

Is there a way to tell jre 1.8 to restrict itself to jre 1.7-- and thus give compile-time errors on lambda expressions, etc, all the additional features of Java 8? is there a way of doing this without explicitly installing Java 7 on my disk?

EDIT

Configuring the Java version isn't making it. I also tried specifying the Java version in pom.xml.

EDIT 2

installed Java 7 already- the best way i guess. thx for the comments.

ash__999
  • 161
  • 1
  • 1
  • 11
  • https://developers.google.com/eclipse/docs/jdk_compliance – OldProgrammer Jan 15 '18 at 20:56
  • @OldProgrammer that didn't work - tried again after your comment. – ash__999 Jan 15 '18 at 21:04
  • No. Why not install both JREs/JDKs? Eclipse can handle multiple JREs. – howlger Jan 15 '18 at 21:06
  • Does this answer your question - [How to change JDK version for an Eclipse project](https://stackoverflow.com/q/12588537)? Or maybe this one - [Setting JDK in Eclipse](https://stackoverflow.com/q/13635563) – Bernhard Barker Jan 15 '18 at 21:06
  • 4
    well, the JRE will not give compile-time errors since it is only for running and not compiling. It should be the JDK that gives compile-time erros... The compiler has options (`-target` and `-souce`) to control the version for which to compile, Eclipse has the compliance level for this - which sure **does** work, compiling with eclipse ("that didn't work" is not very helpful)! I also advice to install and use the correponding JRE in the Build Path (or risk using non-existent methods/classes). – user85421 Jan 15 '18 at 21:07
  • Just set target platform to 1.7 either from eclipse (project props) or maven (if you are using maven) – Antoniossss Jan 15 '18 at 21:31
  • Just keep in mind that this still wont give you 100% compatilility w with JRE 1.7. There was infamous `Map` related change that breaks compatiliblity and will fail to run on 1.7 if compiled with JDK 1.8 - yep, i had to deal with that in the past. – Antoniossss Jan 15 '18 at 21:32

0 Answers0