Wiki source code of Working with the Jars in WebObjects Extensions
Last modified by Pascal Robert on 2008/01/04 19:46
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | The jar files in {{code language="none"}}/Library/WebObjects/Extensions{{/code}} are automatically added to the classpath when a WebObjects application is launched from JavaMonitor or the command line. They are also added to the classpath by Xcode. To make running an application in Eclipse more closely match these other situations, create a **User Library** to match the jar files in **/Library/WebObjects/Extensions**. | ||
2 | |||
3 | {{warning title="Recommendation"}} | ||
4 | Relying on the one version of jars in {{code language="none"}}/Library/WebObjects/Extensions{{/code}} leads to problems when managing multiple applications. i.e., if you update the jars or remove any of them you are required to update potentially every application. Worse, it makes the assumption that your deployment environment matches your development environment! It is therefore highly recommended that you avoid keeping and using jars in {{code language="none"}}/Library/WebObjects/Extensions{{/code}} and instead keep them in your project itself or in a framework that can be embedded in your application. See [[doc:documentation.Home.WOLips Tutorials.Add a Framework Dependency.WebHome]] and [[doc:documentation.Home.WOLips Tutorials.Add a Jar Dependency.WebHome]]. | ||
5 | {{/warning}} | ||
6 | |||
7 | {{tip title="Hint"}} | ||
8 | Afterwards, you will need to then add this library to the build path of any or all relevant projects, and to the launcher for applications and unit tests. | ||
9 | {{/tip}} | ||
10 | |||
11 | To do this, go to Window - Preferences. No, I don't know why they put it under the Window menu. You may get an error the first time you do this. If this happens, close the Preferences window and open it again. Expand the tree on the left like this: | ||
12 | |||
13 | {{info}} | ||
14 | [[image:attach:UserLibraries.jpg]] | ||
15 | {{/info}} | ||
16 | |||
17 | |||
18 | Click **New** and enter **WebObjectsExtensions** as the library name: | ||
19 | |||
20 | {{info}} | ||
21 | [[image:attach:LibraryName.jpg]] | ||
22 | {{/info}} | ||
23 | |||
24 | |||
25 | Click **OK**, select **WebObjectsExtensions**, and click **Add Jars**. Select all the jars in **/Library/WebObjects/Extensions**. The result should look like this (you may not have this exact same set of jars but if you have followed the other instructions you should have the ones that are needed): | ||
26 | |||
27 | {{info}} | ||
28 | [[image:attach:FinalLibraries.jpg]] | ||
29 | {{/info}} | ||
30 | |||
31 | {{warning title="Watch for Updates"}} | ||
32 | This is a **static** list of jars. If anything is added to or modified in **/Library/WebObjects/Extensions**, you will need to manually edit this User Library. | ||
33 | {{/warning}} | ||
34 | |||
35 | After that you added the library to the preferences, you need to add this library to the build path of projects that depends on the jars stored in **/Library/WebObjects/Extensions**. Right-click on the project -> Build Path -> Add Librairies -> User Library, and select **WebObjectsExtensions**. | ||
36 | |||
37 | {{warning}} | ||
38 | If you add this library to your projects and you work with a team, your coworkers should create the library before importing your projects. If not, the library will appear in the project but it will be empty. You can also export the library definition and ask your coworkers to import it. | ||
39 | {{/warning}} | ||
40 | |||
41 | {{tip title="Deployment tip"}} | ||
42 | As noted by the initial recommendation warning, this whole approach assumes that all your applications depend on the same list and version of jars and that your development environment matches your development environment. You should avoid this approach however you can meet this halfway by adding the following to your ant build file. | ||
43 | |||
44 | {{noformat}} | ||
45 | |||
46 | <target name="build.woapp" depends="setProps,init.build,compile"> | ||
47 | <woapplication ...> | ||
48 | <....> | ||
49 | <lib dir="/Library/WebObjects/Extensions"> | ||
50 | <include name="**/*.jar"/> | ||
51 | </lib> | ||
52 | </woapplication> | ||
53 | </target> | ||
54 | |||
55 | {{/noformat}} | ||
56 | |||
57 | This will cause all the jars in {{code language="none"}}/Library/WebObjects/Extensions{{/code}} to be embedded in {{code language="none"}}YourApp.woa/Contents/Resources/Java{{/code}} and added to your application's classpath files. | ||
58 | {{/tip}} |