Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we have jdk6 on jre5?

 
Shyam kumar
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Java Guru's. I have a very simple question.
Can I have jdk 1.6 and only jre5 to execute a java class? Is jdk backward compatible with jre?

Actually i have a scenario. I wanted to write a code to use woodstox parser. Now in documentation it is written that it requires jdk 1.6 wheras I have jdk 1.5 and jre 1.5
I got compilation problems while writing the code. I then installed jdk 1.6 and jre 6. The compilation problems got resoleved and I was able to run the code successfully.
But now I have been told that we cannot change the jre version from 5 to 6. So I was just wondering if I can still have my code run on Jre5 which is compiled using jdk 6

Thanks,
Shyam
 
Henry Wong
author
Marshal
Pie
Posts: 21194
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shyam kumar wrote:Can I have jdk 1.6 and only jre5 to execute a java class? Is jdk backward compatible with jre?


Java is backward compatible -- not forward compatible. Meaning Java 6 can run Java 5 code, but not the other way around. However, you can use the javac "-source" and "-target" flags to compile using only specific constructs, and to generate class files for specific java versions.... Regardless, it is still a good idea to actually have a Java 5 jre installed, as you need to actually test it.

Shyam kumar wrote:I got compilation problems while writing the code. I then installed jdk 1.6 and jre 6. The compilation problems got resoleved and I was able to run the code successfully.


Maybe it would be a good idea to figure out the compilation error instead. After all, when you put the compiler into compat mode, you will likely encounter the same compiler error (if it works correctly).

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic