aspose file tools*
The moose likes Beginning Java and the fly likes Can we have jdk6 on jre5? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can we have jdk6 on jre5?" Watch "Can we have jdk6 on jre5?" New topic
Author

Can we have jdk6 on jre5?

Shyam kumar
Ranch Hand

Joined: May 21, 2006
Posts: 146
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
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can we have jdk6 on jre5?