{"id":936,"date":"2010-09-19T21:50:28","date_gmt":"2010-09-19T21:50:28","guid":{"rendered":"http:\/\/salientsoft.co.uk\/?p=936"},"modified":"2011-11-17T15:17:45","modified_gmt":"2011-11-17T15:17:45","slug":"library-configuration-and-deployment-with-eclipse-helios","status":"publish","type":"post","link":"https:\/\/salientsoft.co.uk\/?p=936","title":{"rendered":"Library Configuration and Deployment with Eclipse"},"content":{"rendered":"<p>I have experimented with the following techniques for managing user defined collections of library jars in a Java EE 6 web application within Eclipse Helios. Much of this follows from <a href=\"http:\/\/www.informit.com\/articles\/article.aspx?p=367962&amp;seqNum=2\">this chapter in Eclipse Distilled<\/a>:-<\/p>\n<ol>\n<li>An interesting method described in \u201cEclipse Distilled\u201d is to use a local <em>simple project<\/em> in the workspace as a library project just to hold eclipse folders to plant the jar collections in. This then allows all other projects in the workspace to reference the jars using relative workspace references, which gives complete portability to the workspace across different locations and operating systems. It does not however allow the library collections to be designated via a single name in the way that <em>user libraries<\/em> do \u2013 you end up with a just a pile of jars on the build path of a referencing project. You can however at least add them all at once via multi select of the jars from a folder in the library project.<\/li>\n<li>Another way is to use <em>User Libraries<\/em>, again as in the above chapter. They have the benefit of allowing a single name to designate the collection of jars, they can be used from anywhere in the workspace, and they can also be exported and imported between workspaces along with other workspace settings. The drawback is that the library location must be defined as an absolute file system location, which means that unlike the above method, you can\u2019t just copy a workspace with all the libraries in it to somewhere completely different and have it \u2018just work\u2019 \u2013 you have to set up the library locations. However, you also have to typically do this for JSF and JRE libraries, so unless you have a lot of them it is not such a chore.<\/li>\n<li>Another mechanism is to use eclipse <em>Classpath Variables<\/em>, which allow a folder location in the filesystem to be defined and then used via a name. Again, the definitions need to be set up on each different system\/location that you migrate the workspace to.<\/li>\n<li><em>Classpath Containers<\/em> are a dynamic form of reference where a named reference is intercepted by code in a class. This is used by plugins, and allows the definition to change dynamically in response to other environmental changes detected by the plugin code.<\/li>\n<\/ol>\n<p>On balance, in the absence of a plugin\/Classpath Container approach, my favoured option is to use <em>User Libraries<\/em> for tools like Primefaces as they are convenient and look tidy on the build path even when it gets large. In an ideal world, it would be helpful if <em>User Libraries<\/em> allowed workspace relative references. This would permit the libraries to be packaged within the workspace which would mean no setup is needed to port the workspace. The downside is that when multiple workspaces are used, you end up with library duplication unless you use an absolute location outside the workspaces. However, you could have a <em>libraries<\/em> folder under a parent folder above all the workspaces. Then if a relative reference like <em>..\\libraries<\/em> was permitted you get your cake and eat it \u2013 no duplication and a portable collection of workspaces with a single copy of all the associated libraries.<\/p>\n<p>However for now, it\u2019s <em>User Libraries<\/em> for me. To create a User Library for a project in Eclipse, do the following :-<\/p>\n<ol>\n<li>Select <em>project properties\/build path\/Configure build path<\/em>, then select the <em>Libraries<\/em> tab in the right hand pane.<\/li>\n<li>Click <em>Add Library\u2026<\/em>, select <em>User Libraries<\/em>, and hit <em>Next<\/em>.<\/li>\n<li>Click <em>User Libraries\u2026<\/em> which will display the User libraries page.<\/li>\n<li>Click <em>New<\/em> to add a library, then add jar(s) to it with <em>Add Jars\u2026<\/em><\/li>\n<li>Having added a jar, you can expand its definition using the tree control in the middle pane, and then double click on <em>javadoc location<\/em>, and\/or <em>Source attachment <\/em>to add a jar or zip containing the javadocs\/source for the jar.<\/li>\n<li>The library is then accessible from all the projects in your Workspace. You can export it to other workspaces by using <em>File\/Export\/Preferences.<\/em><\/li>\n<li><strong>Note<\/strong> that typically you need to tell Eclipse to deploy the libraries to <em>WEB-INF\\lib<\/em> when deploying. Under Eclipse Helios, you do this using the <em>Deployment Assembly<\/em> options page under the project properties, adding an entry for each library you need deploying. When adding, you can elect to add from the java build path, which makes the most sense if you are deploying libraries you have added to the build path. <strong>Note<\/strong> that in previous versions of Eclipse, this option on the project properties was designated <em>J2EE Module Dependencies.<\/em><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>I have experimented with the following techniques for managing user defined collections of library jars in a Java EE 6 web application within Eclipse Helios. Much of this follows from this chapter in Eclipse Distilled:- An interesting method described in \u201cEclipse Distilled\u201d is to use a local simple project in the workspace as a library [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[9,113,16,15],"_links":{"self":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/936"}],"collection":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=936"}],"version-history":[{"count":6,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/936\/revisions"}],"predecessor-version":[{"id":937,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/936\/revisions\/937"}],"wp:attachment":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}