1

I have created a project in Java Eclipse which uses java 1.7. But I need to run some specific modules in it using java 1.8.

Is it possible? How?

5
  • 4
    Can't you use 1.8 for all modules? Commented Jul 20, 2016 at 6:46
  • 1
    1.8 Should be backwards compatible with 1.7, you only need 1.8. Commented Jul 20, 2016 at 6:47
  • You might start up two JVMs and use some sort of interprocess-communication like sockets. But apart from that - no, just use the higher java version. Commented Jul 20, 2016 at 6:51
  • I am using LifeRay bundle which has most of the features supporting 1.7 and not 1.8 and I can't ignore that. Commented Jul 20, 2016 at 6:51
  • You can't. You can't use a Java 7 and a Java 8 VM run your code, unless you make a distribute service or something. Otherwise, you either have to drop the Java 1.8 modules, or wait for LifeRay 7. Commented Jul 20, 2016 at 6:56

2 Answers 2

1

you can set the Java compiler level only project wise not the module wise. So in your case you should set the compiler level 1.8 which will support both the version. In eclipse you can set the compiler level by below option. Right click on Project->Properties->Java Compiler.

Sign up to request clarification or add additional context in comments.

Comments

-1

Simply spoken: you shouldn't do that.

If you are really talking about one project; then you have to make sure that all "components" within your project are on compatible levels.

In your case: if component A requires Java 1.8; and others are fine with 1.7 ... then you should go forward and use 1.8 (you still can use libraries that were compiled for older versions of Java; no need to update/recompile them). And well, if one part needs 1.8; and another only works 1.7 ... then there is no easy solution to that.

The point is: if you deviate from this practice, you will have to use multiple JVMs later on to run your "single" project - and that is of course a contradiction in itself.

The alternative is to dissect the one project you have right now into smaller parts (nowadays you would call them microservices) and define an architecture that allows you to run different parts of your application using different technology. But as others have pointed out: that adds a whole new layer of complexity to your setup.

Comments

Your Answer

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.