Recipe 4.8 Selecting the Java Runtime for Builds


4.8.1 Problem

You want to target your code at a particular JRE, or change the default JRE that Eclipse uses.

4.8.2 Solution

You can specify what Java runtime you want Eclipse to use by selecting Window Preferences, clicking Installed JREs, and choosing the JRE you want (use the Add button to add JREs and SDKs).

4.8.3 Discussion

When you first run Eclipse, it searches for installed Java runtimes , which means it might not use the one you want to use. For example, Eclipse might want to use the outdated JRE that came with your browser instead of the new Java SDK you've just downloaded. To specify what runtime to use, select Window Preferences, click Installed JREs, and choose the JRE you want, as shown in Figure 4-14.

Figure 4-14. Choosing a JRE

To set a project-specific JRE (as when you want to target a project to a specific JRE), select Project Properties Java Build Path, click the Libraries tab, click JRE System Library, and click Edit. In the dialog that appears, select a project-specific JRE. Setting the JVM using the -vm switch

Eclipse might not start if the JRE it finds is too old. In this case, start Eclipse from the command line and use the -vm switch, specifying the JRE you want to use. For example, you might type:

 eclipse -vm c:\jre1.4\bin\javaw.exe 

After Eclipse starts, set the JRE you want to use from then on.

4.8.4 See Also

Recipe 4.9 on running code; Chapter 2 of Eclipse (O'Reilly).

Eclipse Cookbook
Inside XML (Inside (New Riders))
ISBN: 596007108
EAN: 2147483647
Year: 2006
Pages: 232
Authors: Steve Holzner

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: