7

I am using Java 1.7 in my code, now i want to replace JAVA 1.7 to JAVA 1.8.Is Java 1.8 compatible to Java 1.7. ? Will it work as it before. i mean, all new features of Java 1.8 can be used in the existing piece of code?

Darshan Patel
3,2546 gold badges29 silver badges50 bronze badges
asked Jan 28, 2014 at 9:51
10
  • 4
    Java 8 isn't officially released yet, so you could argue no one can know 100% for sure yet. Commented Jan 28, 2014 at 9:53
  • No. If you use JDK1.8 specific features those aren't going to work on a 1.7 JRE/JDK. If you don't use any specific Java8 features and compile to 1.7 it should still will work. Commented Jan 28, 2014 at 9:53
  • 2
    @JqueryLearner Really? Do you have a source for that? Commented Jan 28, 2014 at 9:56
  • 1
    @Kayaman Thread#stop will be removed---not its declaration, but its implementation. I don't know of any other examples, though. Commented Jan 28, 2014 at 9:58
  • 2
    @StephenC Only the Thread#stop(Throwable) overload has been removed. Reference: cs.oswego.edu/pipermail/concurrency-interest/2013-July/… Commented Jan 28, 2014 at 10:10

2 Answers 2

10

The existing piece of code will (ipso facto) not be using any new features of Java 8. If you have a piece of code which works1 on Java version v, it will also work on all other versions v'> v. That is the long-standing promise of the Java platform.


1 By "works" I mean "works as specified, using non-deprecated official JDK APIs".

answered Jan 28, 2014 at 9:55
Sign up to request clarification or add additional context in comments.

3 Comments

As long as your code only depends on public APIs and the Java platform specification, e.g. playing with Unsafe or relying on implementation details like string interning is not covered by that promise.
Not all software is this way. For a prominent example, the GATK which is a genome-analysis toolkit developed by the Broad Institute. It is only compatible with java 1.7, and will throw exceptions if the Java version is 1.8.
@carbocation The reason may well be that it uses deprecated and/or proprietary APIs which are not part of the JavaSE public API.
-3

It depends.

Your question is a little unclear. "Will it work as before" and "All new features of Java 8 can be used in the existing piece of code" seem mutually exclusive.

If you are using a Lambda Expression (Java 8 feature) you will not be able to compile using JDK7. Conversely if you are compiling using JDK7 you will not be able to use any of the new features in JDK8.

TL;DR: If you have to ask, it probably won't.

answered Jan 28, 2014 at 10:06

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.