• Post Reply Bookmark Topic Watch Topic
  • New Topic

Multiple versions of java applications in one jvm  RSS feed

 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jvm in production with multiple applications on it. I have upgraded that jvm with java 7. I am thinking of upgrading one application at a time to java 7, meaning recompiling each application using java 7 and deploying to production at DIFFERENT times. I believe applications with different java versions can co-exist in jvm version 7. Please correct me if I am wrong.
 
Greg Charles
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java is generally very good about staying backward compatible. That is, you should be able to compile code written for earlier versions of Java with the Java 7 JDK. You should also be able to run those applications with a Java 7 JVM, even without recompiling them. There are a few exceptions to this general rule, so take it slow, and make sure to test thoroughly.

Conversely, Java generally doesn't guarantee forward compatibility, so don't expect something compiled with Java 7 to run under an earlier JVM, and don't expect code written for Java 7 to compile with an earlier JDK. I ran into this a couple of years ago with a project that was locked into using Java 1.4, but wanted to introduce Jasper Reports. It was a huge problem digging up a version of Jasper that would run under their ancient JVM.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also have a look at this recent thread about a similar subject.
 
PradeepPillai Pradeep
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. So if I have 3 application – App1, App2, and App3 - on that java 7 jvm, I can have:
App1 compiled using java 7,
App2 compiled using java 6, and
App 3 compiled using java 5, correct?
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As long as you have no apps created with Java8 you should be able to run everything.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you do not need to recompile your code for a newer JVM.

Oracle (and formerly Sun) have always been extremely careful with backward compatibility. However, there might be a few special cases that cause problems. Most likely it will work without problems if you upgrade your JVM, but you should always test it on a test system before upgrading a production system.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!