gamelan
Search EarthWeb
CodeGuru | Gamelan | Jars | Wireless | Discussions
Navigate developer.com
Architecture & Design  
Database  
Java
Languages & Tools
Microsoft & .NET
Open Source  
Project Management  
Security  
Techniques  
Voice  
Web Services  
Wireless/Mobile
XML  
Technology Jobs  

   Developer.com Webcasts:
  The Impact of Coding Standards and Code Reviews

  Project Management for the Developer

  Defining Your Own Software Development Methodology

  more Webcasts...




See the Winners!


Developer Jobs

Be a Commerce Partner
Computer Hardware
Domain registration
Hurricane Shutters
KVM Switch over IP
Promotional Gifts
Career Education
Laptop Batteries
Promos and Premiums
Baby Photo Contest
Shop Online
Online Education
Dental Insurance
Corporate Awards
Car Donations

 


Storage Networking , Part 1
eBook: A storage network is any network that's designed to transport block-level storage protocols. But understanding the ins and outs of networked storage takes you deep into several of protocols. This guide covers SANs, Fibre Channels, Disk Arrays, Fabric, and IP Storage. »

Storage Networking 2, Configuration and Planning
eBook: Picking up where Part 1 left off, Part 2 of our look at storage networking examines configurations for SAN-attached servers and disk arrays, and also includes a look at the future of IP storage. »

Storage Management Costs in the Enterprise: A Comparison of Mid-Range Array Solutions
Whitepaper: Many factors contribute to the ownership cost for enterprise storage. These include (but are not limited to): physical capacity relative to physical space requirements, performance capacity for data transfer and system reaction time, software maintenance and updates, expandability and flexibility, and much more. »

Storage Is Changing Fast  Be Ready or Be Left Behind
PDF: The storage landscape is headed for dramatic change, thanks to new technologies like Fibre Channel over Ethernet (FCoE), pNFS, object-based storage and SAS that will affect everything from NAS and SANs to disk drives. Get the knowledge you need to make the most of your storage environment, now and in the future. »

HP StorageWorks EVA4400
Demo: Dont settle for an expensive and complex array that lacks functionality. The HP StorageWorks EVA4400 delivers virtual storage with enterprise class functionality at an affordable price. »

Related Article -
Eclipse Tip: How to Live on the Cutting Edge
Programming the Eclipse Workbench
Developer News -
SaaS Tool Offers Custom Database Development    May 9, 2008
Microsoft’s Automated Agent: Can We Talk?    May 7, 2008
Borland Finally Sells CodeGear    May 7, 2008
Red Hat Heads For The JON 2.0    May 7, 2008
Free Tech Newsletter -

Best Practices for Developing a Web Site: Checklists, Tips, Strategies & More. Download Exclusive eBook Now.

Eclipse Tip: Use the Execution Environment to Create Portable Java Projects
By Peter Nehrer

In Eclipse, creating Java projects is easy—you invoke the New Java Project wizard, enter the new project's name, click Finish, and you're done. If you need to modify the default project configuration, you can do so right there in the wizard, or accept the defaults and make changes later.

When setting up a larger project, such as one that you plan to share with others, you should try to keep its configuration as portable as possible. For example, you should avoid using absolute paths when linking to resources, minimize the use of user-defined path variables, and so forth. This will simplify development environment setup for other developers who want to participate.

Specifying the JRE System Library

One particularly important project configuration property is the JRE System Library. It is the fundamental dependency that dictates which Java Runtime Environment your code is compiled against. You must have at least one JRE installed on your system to be able to run Eclipse. By default, this is the JRE used for all new projects.



Click here for a larger image.

Figure 1: Workbench Preferences page listing Execution Environments and their corresponding compatible JREs.

As you know, today's world of Java is not constrained to one version. Even though the latest stable release is version 5, many companies still use 1.4 and even 1.3. The brave developers may be experimenting with the latest beta release of Mustang (Java SE 6). Eclipse 3.2, at a minimum, requires Java 1.4 to run; however, you can use Eclipse to develop software for other versions of Java, regardless of the JRE used to run your IDE: In your Workbench Preferences, go to Java -> Installed JREs and add as many JREs as you like (of course, you have to obtain and install them first). When creating a new Java project, the wizard will let you select a JRE other than the default one.

This feature is very useful particularly when you want your code to work with older versions while running your Eclipse IDE in a newer JRE (otherwise, you'd have to exercise a great deal of caution to avoid inadvertently introducing dependencies on new APIs). However, it doesn't necessarily keep your projects portable; every JRE you add to your preferences is uniquely named. The name is defaulted to the JRE's installation directory. If you set up a project to use a JRE other that the default one, its name will be recorded in the project's JDT configuration (in other words, the .classpath file). But, what if other developers have a slightly different version of the required JRE (for example, j2re1.4.2_03 vs. j2sdk1.4.2_11), or simply name theirs differently? They'd get a nasty "Unbound classpath container: 'JRE System Library [j2sdk1.4.2_11]'" error after importing your project into their workspace. Sure, you can use an agreed-upon JRE name, but there is a better way....

Specifying the Java Execution Environment



Click here for a larger image.

Figure 2: Plug-in Manifest Editor lets you specify one (or more) Execution Environments for the plug-in.

Since version 3.2, Eclipse supports the notion of Execution Environment. It is essentially an alias for JREs matching a certain version of Java; for example, J2SE-1.4 covers all JREs compatible with Java 2 Standard Edition 1.4 (this, by the way, includes later versions, such as 5 and 6). To see the available execution environment definitions, open your Workbench Preferences and go to Java -> Installed JREs -> Execution Environments. Clicking an execution environment will display all compatible JREs that you configured. The ones that are a "perfect match" are highlighted. If you have multiple matching JREs, you may check the one you prefer to use.

As you can see, execution environments are much more portable than specific JREs. But, how do you set up your project to use one? The New Java Project wizard won't let you do it on the first page; however, you can click Next and select the Libraries tab on the next page. In it, select JRE System Library and click Edit. You will see a dialog that lets you choose an Execution Environment as an alternative to a specific JRE.

Alternatively, you can reconfigure your project after it is created. In the Package Explorer, right-click your project's JRE System Library node and choose Configure... from the context menu.

What About the Plug-ins?

Even though Eclipse Plug-in projects are essentially set up as specialized Java projects, it is not recommended to modify their Java Build Path settings directly. This is because the Plug-in project configuration is managed by the PDE. Luckily, the Plug-in Manifest Editor provides support for specifying the required Execution Environment for plug-ins. In fact, you can choose more than one. In the Overview page, there is an Execution Environments section that lets you do just that. After you add the desired execution environments to the list, click the Update the classpath and the compiler compliance settings link below it. This will not only update your project's Java Build Path, but also its compiler settings to match the language level corresponding to the selected environment (for example, Java Generics are only supported in J2SE-1.5 and later, the "assert" keyword in 1.4, and so on.)

The chosen execution environments also are recorded in the plug-in's manifest. At runtime, Eclipse will refuse to run a plug-in unless the runtime JRE is compatible with the plug-in's execution environment specification. (In other words, a plug-in may specify its minimum required execution environment.)

For more information about this feature, see the latest Eclipse Help:

About the Author

Peter Nehrer is a software consultant specializing in Eclipse-based enterprise solutions and J2EE applications. He is the founder of Ecliptical Software Inc. and a contributor to several Eclipse-related Open Source projects. He holds an M.S. in Computer Science from the University of Massachusetts at Amherst, MA. Peter can be reached at pnehrer AT eclipticalsoftware DOT com.


Tools:
Add www.developer.com to your favorites
Add www.developer.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed


Enterprise Java Archives

Whitepaper: Embeddable Content Platform for OEM's
Five Trends for Application Development & Program Management. Download Complimentary Report Now.
Developing Intelligent Communications? Visit the Avaya DevConnect Center on DevX.
Whitepaper: Enterprise Information Integration--Deployment Best Practices for Low-Cost Implementation
Learn about expanding business opportunities for the reseller channel. Visit IT Channel Planet.



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES