This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with JRE compatibility

 
abhinav sinha
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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
Marshal
Pie
Posts: 65110
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
abhinav sinha
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for guiding me to the correct forum.I hope I will get a quick help now.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
abhinav sinha
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18276
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic