Project

General

Profile

1
<!--
2
  * sitemaps.html
3
  *
4
  *      Authors: Michael Daigle
5
  *    Copyright: 2008 Regents of the University of California and the
6
  *               National Center for Ecological Analysis and Synthesis
7
  *  For Details: http://www.nceas.ucsb.edu/
8
  *      Created: 2008 November 4
9
  *      Version: 
10
  *    File Info: '$ '
11
  * 
12
  * 
13
-->
14
<HTML>
15
<HEAD>
16
<TITLE>Setting Up a Metacat Eclipse Project</TITLE>
17
<!-- unfortunately, we have to look for the common css file in the 
18
     user docs directory.  This is because the user docs deploy to 
19
     the top level of the metacat docs on the knb web server -->
20
<link rel="stylesheet" type="text/css" href="../user/common.css">
21
<link rel="stylesheet" type="text/css" href="./default.css">
22
</HEAD> 
23
<BODY>
24
  <table width="100%">
25
    <tr>
26
      <td class="tablehead" colspan="2"><p class="label">Setting Up a Metacat Eclipse Project</p></td>
27
      <td class="tablehead" colspan="2" align="right">
28
        <a href="./metacat-dev-hardware.html">Back</a> | <a href="./index.html">Home</a> | 
29
        <a href="./building-metacat.html">Next</a>
30
      </td>
31
    </tr>
32
  </table>
33
    
34
    <p> The following are the steps to download Eclipse, load the Metacat project and
35
    its dependent projects, set up the environment, and run Metacat via Tomcat from
36
    within Eclipse.</p>
37
    
38
    <p> One note, these instructions are based on my development system, which is a Linux
39
    system.  I rarely use
40
    apt-get install (debian) or yum install (fedora) to install supporting applications
41
    like Java, Tomcat and Apache.  This is because I want a certain level of control
42
    over where these apps are installed, and I like to be able to install several 
43
    versions side by side so I can switch back and forth in my development environment.</p>
44
    
45
    <p> My typical approach is to install the application in the /usr directory.  Then I 
46
    create a symlink from /usr/local to this install.  Any environment variables reference
47
    this symlink, so I can easily modify the symlink to change the version of the 
48
    application.</p>
49
    
50
	<p><div class="header3">Install Java (assuming it's not already installed):</div>
51
	<ul>
52
		<li>go to <a target="_blank" href="http://java.sun.com/javase/downloads/index.jsp">Java Download Site</a>.</li>
53
		<li>download the Java SE Development Kit for your platform (I use the regular .bin file, not the
54
		   rpm.bin).</li>
55
		<li>make the java usr directory:  <code>sudo mkdir /usr/java</code></li>
56
		<li>move the jdk .bin file you downloaded into the java user dir: 
57
			<code>sudo mv jdk-6u19-linux-i586.bin /usr/java</code></li>
58
		<li>make bin file executable: <code>sudo chmod +x jdk-6u19-linux-i586.bin</code></li>
59
		<li>run the bin file: <code>sudo ./jdk-6u19-linux-i586.bin</code></li>
60
		<li>create java symlink in /usr/local: <code>ln -s /usr/java/jdk1.6.19/ /usr/local/java</code>
61
		<li>add the following lines to /etc/profile (again, this is my preference):<br>
62
		    <code>&nbsp;&nbsp;&nbsp;&nbsp;JAVA_HOME=/usr/local/java</code><br>
63
		    <code>&nbsp;&nbsp;&nbsp;&nbsp;PATH=$JAVA_HOME/bin:$PATH</code><br>
64
		    <code>&nbsp;&nbsp;&nbsp;&nbsp;export PATH JAVA_HOME</code>
65
		</li>
66
	</ul>
67
	
68
	<p><div class="header3">Install Tomcat (assuming it's not already installed):</div>
69
	<ul>
70
		<li>go to <a target="_blank" href="http://tomcat.apache.org/download-60.cgi">Tomcat Download Site</a>.</li>
71
		<li>download the binary core tar.gz file.</li>
72
		<li>make the tomcat usr directory:  <code>sudo mkdir /usr/tomcat</code></li>
73
		<li>move the tar.gz file you downloaded into the tomcat user dir: 
74
			<code>sudo mv apache-tomcat-6.0.26.tar.gz /usr/tomcat</code></li>
75
		<li>expand tar.gz: <code>sudo tar -xvzf apache-tomcat-6.0.26.tar.gz</code></li>
76
		<li>create tomcat symlink in /usr/local: <code>ln -s /usr/tomcat/apache-tomcat-6.0.26/ /usr/local/tomcat</code>
77
		<li>add the following lines to /etc/profile (again, this is my preference):<br>
78
		    <code>&nbsp;&nbsp;&nbsp;&nbsp;TOMCAT_HOME=/usr/local/tomcat</code><br>
79
		    <code>&nbsp;&nbsp;&nbsp;&nbsp;PATH=$TOMCAT_HOME/bin:$PATH</code><br>
80
		    <code>&nbsp;&nbsp;&nbsp;&nbsp;export PATH TOMCAT_HOME</code>
81
		</li>
82
	</ul>
83
	</p>
84
	
85
	<p><div class="header3">Download and Install Eclipse:</div>
86
	<ul>
87
		<li>go to <a target="_blank" href="http://www.eclipse.org/downloads/">Eclipse Download Site</a>.</li>
88
		<li>choose Eclipse IDE for Java Developers</li>
89
		<li>make the eclipse usr directory:  <code>sudo mkdir /usr/eclipse</code></li>
90
		<li>move the tar.gz file you downloaded into the eclipse user dir: 
91
			<code>sudo mv eclipse-java-galileo-SR2-linux-gtk.tar.gz /usr/eclipse</code></li>
92
		<li>extract tar.gz: 
93
		   <code>sudo tar -xvzf eclipse-java-galileo-SR2-linux-gtk.tar.gz</code></li>
94
		<li>note that Eclipse extracts into a folder named eclipse.  I like to rename this
95
		folder using the SR number or current date, in case I want to put another version of 
96
		eclipse next to it. So: <br>&nbsp;&nbsp;&nbsp;&nbsp;<code>mv /usr/eclipse/eclipse /usr/eclipse/eclipse-galileo-SR2</code></li>
97
		<li>create eclipse symlink in /usr/local: <code>ln -s /usr/eclipse/eclipse-galileo-SR2 /usr/local/eclipse</code>
98
		<li>add the following lines to /etc/profile (again, this is my preference):<br>
99
		    <code>&nbsp;&nbsp;&nbsp;&nbsp;ECLIPSE_HOME=/usr/local/eclipse</code><br>
100
		    <code>&nbsp;&nbsp;&nbsp;&nbsp;PATH=$ECLIPSE_HOME:$PATH</code><br>
101
		    <code>&nbsp;&nbsp;&nbsp;&nbsp;export PATH ECLIPSE_HOME</code>
102
		</li>
103
		<li>I create a desktop launcher for Eclipse.  The command should just be <code>eclipse</code>.
104
		If that doesn't work, you may need to log out and log in to pick up changes in 
105
		<code>/etc/profile</code>.  You can associate the launcher with the eclipse icon
106
		at <code>/usr/local/eclipse/icon.xpm</code></li>
107
	</ul>
108
	</p>
109

    
110
	<p><div class="header3">Get Subversion plugin:</div>
111
	<p>The subversion plugin allows you to checkout and manage your code against
112
	an SVN repository</p>
113
	<ul>
114
		<li>in eclipse, go to Help/Install New Software</li>
115
		<li>add the following update site: <code>http://subclipse.tigris.org/update_1.6.x</code>
116
		Note this may change for newer versions.
117
		Check <a target="_blank" href="http://subclipse.tigris.org/">Subclipse Site</a> for newer versions</li>
118
		<li>Choose to install all the packages under that site</li>
119
		<li>After restarting Eclipse, you should see an SVN Repository Exploring
120
		perspective available.</li>
121
	</ul>
122
	</p>
123

    
124
	<p><div class="header3">Check out metacat code:</div>
125
	<ul>
126
		<li>In eclipse go to the SVN Repository Exploring perspecitve</li>
127
		<li>Click in window under svn repositories and chosse "New > Repostory Location ..."</li>
128
		<li>Add <code>https://code.ecoinformatics.org/code/metacat</code></li>
129
		<li>Add <code>https://code.ecoinformatics.org/code/utilities </code></li>
130
		<li>If you are actively working on ecogrid, add <code>https://code.ecoinformatics.org/code/seek</code></li>
131
		<li>For each repository, open its tree and right click on trunk </li>
132
		<li>Choose "checkout..."</li>
133
		<li>Check out as a project using the wizard</li>
134
		<li>Choose java project</li>
135
		<li>Name the project in workspace. One thing to keep in mind is that the build
136
		process relies on the Metacat code being in a directory named "metacat".  If you will
137
		absolutely only have one metacat project, you can name it "metacat".  Otherwise, I usually
138
		name the project something meaningfull, like "METACAT_TRUNK" or "METACAT_1_9_1_RC2".  Then
139
		I create a "metacat" simlink at the same level that points to the checkout that I 
140
		actually want to build.</li>
141
		<li>Note, if you want to check out a certain branch or tag, browse to that tag in the tree and follow the same steps as above.</li>
142
	</ul>
143
	</p>
144

    
145
	<p><div class="header3">Set up Metacat Dependencies</div>
146
	<p>These dependencies are primarily so you can eliminate reference errors in
147
	the code and so you can debug when running in tomcat.</p>
148
	<ul>
149
		<li>In the Java perspective, hilight the utilities project you checked out.</li>
150
		<ul>
151
			<li>In the menu, go to Project > Properties > Java Build Path</li>
152
			<li>Choose the libraries tab and Add Jars...</li>
153
			<li>Select all the jar files in the utilities/lib directory</li>
154
			<li>Switch to the Source tab and remove utilities/src</li>
155
			<li>Add folder utilties/src/java</li>
156
		</ul>
157
		<li>In the Java perspective, hilight the metacat project you checked out.</li>
158
		<ul>
159
			<li>In the menu, go to Project > Properties > Java Build Path</li>
160
			<li>Choose the libraries tab and Add Jars...</li>
161
			<li>Select all the jar files in the metacat/lib directory EXCEPT the 
162
			    utilities.jar if it exists.</li>
163
			<li>Select all the jar files in the metacat/lib/lsid_lib directory</li>
164
			<li>Select all the jar files in the metacat/lib/oaipmh directory</li>
165
			<li>Select all the jar files in the metacat/lib/spatial/geoserver/WEB-INF/lib directory</li>
166
			<li>Choose to Add External Jars and select all the jar files in /usr/local/tomcat/lib</li>
167
			<li>Switch to the Projects tab and add the utilities project.</li>
168
		</ul>
169
		<li>These settings should remove all but the most persistant error markers in
170
		the code.</li>
171
	</ul>
172
	</p>
173
	
174
	<p><div class="header3">Build Metacat</div>
175
	<p>A full description of how to build Metacat is beyond the scope of this document, however
176
	you should be able to do all Ant tasks from within eclipse.</p>
177
	<ul>
178
		<li>In Eclipse choose Window > Show View > Ant</li>
179
		<li>You should see an Ant window pop up on the right.</li>
180
		<li>In the Metacat project, select the build.xml file and drag it to 
181
			the Ant window.</li>
182
		<li>All Ant tasks should now be runnable from this window</li>
183
	</ul>
184
	</p>
185

    
186
	<p><div class="header3">Set up Tomcat in Eclipse:</div>
187
	<ul>
188
		<li>Get tomcat eclipse plugin at: 
189
		    <a target="_blank" href="http://www.eclipsetotale.com/tomcatPlugin.html">Tomcat Plugin Site</a></li>
190
		<li>Extract zip: <code>sudo unzip tomcatPluginV321.zip</code></li>
191
		<li>move resulting dir into Eclipse plugins directory: <br>
192
			<code>&nbsp;&nbsp;&nbsp;&nbsp;sudo mv com.sysdeo.eclipse.tomcat_3.2.1 /usr/locale/eclipse/plugins</code></li>
193
		<li>Restart Eclipse. You should see some Tomcat icons in the toolbar.</li>
194
		<li>In Eclipse go to Window > Preferences > Tomcat </li>
195
		<li>Set Tomcat version to correct value (6 recommended)</li>
196
		<li>Set tomcat home to directory where you just installed tomcat 
197
		   (<code>/usr/local/tomcat</code> if you used my instructions).</li>  
198
		<li>Under "Advanced", add Metacat and Utilities projects to Tomcat classpath</li>
199
		<li>You can now start and stop Tomcat using the Tomcat menu or toolbar items.
200
			The application output will show up in the console tab in Eclipse.  Note
201
			that there is also now a Debug perspective.  You can perform the standard
202
			debugger actions on your running Metcat instance via this perspective.</li>
203
	</ul>
204
	</p>   
205
    
206
    <p><div class="header3">Advanced Operations:</div><p>
207
    <p>There are many more advanced operations that can be performed from within
208
    Eclipse, including running individual classes, regular expression searching, 
209
    jumping to implementation source and more.  Please refer to 
210
    <a target="_blank" href="http://www.eclipse.org/documentation/">Eclipse Documentation</a>
211
    for more information.</p> 
212
    
213
  <br>
214
  <a href="./metacat-dev-hardware.html">Back</a> | <a href="./index.html">Home</a> | 
215
  <a href="./building-metacat.html">Next</a>
216
  </ul>
217

    
218
</BODY>
219
</HTML>
(18-18/36)