File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes IDEs, Version Control and other tools and the fly likes Problem with JRE compatibility Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Problem with JRE compatibility" Watch "Problem with JRE compatibility" New topic

Problem with JRE compatibility

abhinav sinha

Joined: Nov 29, 2007
Posts: 22

I wrote code using Eclipse IDE . My system has Java 1.6 installed but the required code needed to run on JRE 1.5 machines also so I set the compliance level to JDK 1.5 in the Eclipse IDE. My knowledge was that even if my machine has JDK 1.6 installed,if I set the compliance level to JDK 1.5 in the Eclipse,my code will comply with the Java 1.5 APIs and run fine on JRE 1.6 as well as JRE 1.6. But after development,my tool went to customer sites and I have come to know that it is not running on machines with JRE 1.5. Can anybody tell me what went wrong?Please correct me if my knowledge was wrong.Have I followed wrong procedure?Please explain in detail as I am new to java.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

Please take the time to choose the correct forum for your posts. This forum is for questions on advanced Java.

For more information, please read this.

This post has been moved to a more appropriate forum.

[Asking smart questions] [About Bear] [Books by Bear]
abhinav sinha

Joined: Nov 29, 2007
Posts: 22
Thanks a lot for guiding me to the correct forum.I hope I will get a quick help now.
Peter Johnson

Joined: May 14, 2008
Posts: 5852

In project properties, under "Java Compiler", did you also set the "Generated .class files compatibility" to 1.5? And then under Java Build Path, on the Libraries tab, make sure that a 1.5 JDK is listed.

To register a 1.5 JDK with Eclipse and make that the default JDK, go to Windows > Preferences, and then Java > Installed JREs.

JBoss In Action
abhinav sinha

Joined: Nov 29, 2007
Posts: 22
I have not registered JDK 1.5 in Installed JREs. For that I will have to Download JDK 1.5 first (right now I only have JDK 1.6 installed on my system)? Can I have 2 JDKs(1.5 and 1.6) installed on the same system?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

You can have as many JVM versions as you like, although on some OS's, it's easier than on others. For example, on Linux, the convention is to keep them all in a /usr/java directory. On Solaris, they put the primary one in the system binary directories and a secondary one under /usr.

I think, however, that all platforms support downloading a JVM as a ZIP file that can be unzipped and used without the need for specialized installation like setting up Windows Registry items.

To select an alternative Java version for most commands, such as Tomcat or WebLogic, you set an environment variable (JAVA_HOME) for the shell that the application is running in.

Eclipse is different, since it's a development platform. For Eclipse, you use the Eclipse Window/Preferences,Java/Installed JRE's dialog to register JVMs.

Finally, note that if you set a project's code compatibility level in Eclipse, but actually do your deployment build with something like Ant or Maven, Eclipse's settings don't count. You actually have to set the java compile commands for Ant or Maven to output to the selected compatibility level. Otherwise, they'll compile to the highest version supported by the JDK you're compiling under.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Problem with JRE compatibility
It's not a secret anymore!