Greenstone 3 can be run as a project inside the [www.eclipse.org Eclipse IDE].
Note: not available for Greenstone 2.
In this document, $GS3SRCHOME is the full path to the top-level folder of your Greenstone 3. Wherever you see $GS3SRCHOME on this wiki page, it means you need to replace it with the full path to your top-level Greenstone 3 folder.
The instructions on this page will refer to Eclipse's Perspectives for Java
and Java Browsing
.
You can swap between Eclipse's Perspective for Java (coding) and Java Browsing by going to:
You can delete an Eclipse Project from the Java Browsing perspective. In the Projects tab, rightclick on the project to be deleted and choose Delete. Beware to only additionally choose to delete the contents on the disk too (and not just the Eclipse project) if you really mean to do that.
The methods in the sections below can be used if you already have an SVN client on your computer. If you don't have SVN, you can instead use the Eclipse plugin Subclipse to checkout Greenstone.
An Eclipse project file is part of the GS3 svn checkout. It consists of a .project file, with associated .classpath file.
Once you've checked out a GS3 from SVN and compiled it up with an ant prepare
command followed by an ant install
command, open up Eclipse.
In Eclipse, create a new workspace, and import this project file. Use File > Import and select General > Existing Projects into Workspace. Click Next and then browse to the GS3 top level directory as this contains the eclipse project file. Once selected, click Finish. (These instructions are from coderanch.)
Check for build errors in Eclipse's Java perspective. If you have any build errors, it means it's probably missing some newer library jar files. In that case, update the .classpath file in GS3's top level directory.
The src/java
, gli/src
and ext/solr/src/java
folders, which contain java code, will be set up for automatic compilation in Eclipse.
Creating an Eclipse project for Greenstone that can be reused with other fresh Greenstone checkouts from SVN.
In an x-term:
svn co http://svn.greenstone.org/main/trunk/greenstone3 greenstone3
Default output folder
to the $GS3SRCHOME/web/WEB-INF/classes folder.$GS3SRCHOME/web/WEB-INF/lib/ant.jar (or [ANT DIRECTORY]/lib/ant.jar) $GS3SRCHOME/web/WEB-INF/lib/axis.jar $GS3SRCHOME/web/WEB-INF/lib/commons-codec-XXX.jar $GS3SRCHOME/web/WEB-INF/lib/commons-fileupload-XXX.jar $GS3SRCHOME/web/WEB-INF/lib/commons-io-2.1.jar $GS3SRCHOME/web/WEB-INF/lib/commons-langXXX.jar $GS3SRCHOME/web/WEB-INF/lib/DLservices.jar $GS3SRCHOME/web/WEB-INF/lib/fedoraGS3.jar $GS3SRCHOME/web/WEB-INF/lib/gson-1.7.1.jar $GS3SRCHOME/web/WEB-INF/lib/jaxrpc.jar $GS3SRCHOME/web/WEB-INF/lib/jdbm.jar $GS3SRCHOME/web/WEB-INF/lib/jna.jar $GS3SRCHOME/web/WEB-INF/lib/jna-platform.jar $GS3SRCHOME/web/WEB-INF/lib/JSON-java.jar $GS3SRCHOME/web/WEB-INF/lib/junit.jar $GS3SRCHOME/web/WEB-INF/lib/log4j-1.2.8.jar $GS3SRCHOME/web/WEB-INF/lib/LuceneWrapper4.jar $GS3SRCHOME/web/WEB-INF/lib/mailapi-1.5.6.jar $GS3SRCHOME/web/WEB-INF/lib/recaptcha4j-XXX.jar $GS3SRCHOME/web/WEB-INF/lib/serializer.jar $GS3SRCHOME/web/WEB-INF/lib/slf4j-api-1.6.6.jar * $GS3SRCHOME/web/WEB-INF/lib/slf4j-jdk14-1.6.6.jar * $GS3SRCHOME/web/WEB-INF/lib/solr-core-4.7.2.jar * $GS3SRCHOME/web/WEB-INF/lib/solr-solrj-4.7.2.jar * $GS3SRCHOME/web/WEB-INF/lib/xalan.jar $GS3SRCHOME/web/WEB-INF/lib/xercesImpl.jar $GS3SRCHOME/web/WEB-INF/lib/xml-apis.jar $GS3SRCHOME/web/WEB-INF/lib/xsltc.jar
*The 2 slf4j*.jar files and 2 solr*.jar files are for compiling what's in ext/solr/src/java.
Next, also add in:
$GS3SRCHOME/lib/java/svnkit.jar $GS3SRCHOME/lib/jni/mg.jar $GS3SRCHOME/lib/jni/mgpp.jar $GS3SRCHOME/lib/jni/javagdbm.jar $GS3SRCHOME/packages/tomcat/lib/servlet-api.jar
apache.jar
, qfslib.jar
, rsyntaxtextarea.jar
and add them too. So you additionally have:$GS3SRCHOME/gli/lib/apache.jar $GS3SRCHOME/gli/lib/qfslib.jar $GS3SRCHOME/gli/lib/rsyntaxtextarea.jar
If project jars are not available for any reason, press the External Jars button, browse to gli's lib folder, and add in the 3 jars there (apache.jar, qfslib.jar, rsyntaxtextarea.jar).
.classpath
file created by Eclipse and remove all occurrences to the full path to the GS3, so that only paths relative to the GS3 toplevel folder remain. For example, all instances of /path/to/GS3/web/WEB-INF/lib would become web/WEB-INF/lib. Save the .classpath
file.greenstone3
.In an x-term
This will reveal the .project and .classpath files that Eclipse generated and placed in your greenstone 3 installation
File → New → Java Project
src
folder and then choose Import.General → File System
. Press Next.$GS3SRCHOME/src/java
folder and press OK.java
folder so that it is checked.*.java
option and press OK.$GS3SRCHOME/gli/src
and $GS3SRCHOME/ext/solr/src/java
as src folders too, then right-click on the Eclipse project folder in the Package Explorer > New > Source Folder. Give it a name like glisrc
or solrsrc
.glisrc
) and then choose Import. Then repeat steps 5-10 for each new code src folder to add.org.greenstone
package.Default output folder
to $GS3SRCHOME/web/WEB-INF/classes
.$GS3SRCHOME/lib/java/svnkit.jar $GS3SRCHOME/lib/jni/mg.jar $GS3SRCHOME/lib/jni/mgpp.jar $GS3SRCHOME/lib/jni/javagdbm.jar $GS3SRCHOME/packages/tomcat/lib/servlet-api.jar
Similarly, also add all the jar files in:
$GS3SRCHOME/web/WEB-INF/lib/ant.jar (or [ANT DIRECTORY]/lib/ant.jar) $GS3SRCHOME/web/WEB-INF/lib/axis.jar $GS3SRCHOME/web/WEB-INF/lib/commons-codec-XXX.jar $GS3SRCHOME/web/WEB-INF/lib/commons-fileupload-XXX.jar $GS3SRCHOME/web/WEB-INF/lib/commons-io-2.1.jar $GS3SRCHOME/web/WEB-INF/lib/commons-langXXX.jar $GS3SRCHOME/web/WEB-INF/lib/DLservices.jar $GS3SRCHOME/web/WEB-INF/lib/fedoraGS3.jar $GS3SRCHOME/web/WEB-INF/lib/gson-1.7.1.jar $GS3SRCHOME/web/WEB-INF/lib/jaxrpc.jar $GS3SRCHOME/web/WEB-INF/lib/jdbm.jar $GS3SRCHOME/web/WEB-INF/lib/jna.jar $GS3SRCHOME/web/WEB-INF/lib/jna-platform.jar $GS3SRCHOME/web/WEB-INF/lib/JSON-java.jar $GS3SRCHOME/web/WEB-INF/lib/junit.jar $GS3SRCHOME/web/WEB-INF/lib/log4j-1.2.8.jar $GS3SRCHOME/web/WEB-INF/lib/LuceneWrapper4.jar $GS3SRCHOME/web/WEB-INF/lib/mailapi-1.5.6.jar $GS3SRCHOME/web/WEB-INF/lib/recaptcha4j-XXX.jar $GS3SRCHOME/web/WEB-INF/lib/serializer.jar $GS3SRCHOME/web/WEB-INF/lib/slf4j-api-1.6.6.jar * $GS3SRCHOME/web/WEB-INF/lib/slf4j-jdk14-1.6.6.jar * $GS3SRCHOME/web/WEB-INF/lib/solr-core-4.7.2.jar * $GS3SRCHOME/web/WEB-INF/lib/solr-solrj-4.7.2.jar * $GS3SRCHOME/web/WEB-INF/lib/xalan.jar $GS3SRCHOME/web/WEB-INF/lib/xercesImpl.jar $GS3SRCHOME/web/WEB-INF/lib/xml-apis.jar $GS3SRCHOME/web/WEB-INF/lib/xsltc.jar
* If ext/solr/src/java
was one of the source folders.
And if you gli/src is one of the source folders, then also add:
$GS3SRCHOME/gli/lib/apache.jar $GS3SRCHOME/gli/lib/qfslib.jar $GS3SRCHOME/gli/lib/rsyntaxtextarea.jar
Press OK.
Note that if compile time errors remain, or errors appear during runtime, you can add try adding any further (or even all) the jars in:
$GS3SRCHOME/web/WEB-INF/lib
You can now edit the Java files and make use of the advanced IDE features as you would normally be able to. This approach does not work very well when you need to change the name of a file or add a new file. In these cases you will probably want to make the modifications directly on the file system and then re-import the specific files affected.
See Eclipse shortcuts which also links to the autoformatting file we hope to use as a standard for Greenstone Java code.
1. Open the GS3 .project Eclipse project file in Eclipse.
2. In the Java perspective view, navigate down to executable java file and right-click on it. E.g. rightclick on the TransformingLibrary.java in src/java/org/greenstone/gsdl3 http://stackoverflow.com/questions/8625060/store-run-configuration-with-project-in-eclipse
3. Choose Run As > Run Configurations.
4. Set up the env variables and arguments to the executable.
5. Store the Run configuration with the project in Eclipse, if you need to commit the launch configuration to SVN. The instructions as explained at Store run configuration with project in Eclipse:
Open "Run" then "Run Configurations...", and select your configuration. Click on the last tab, "Common". Under "Save As", choose "Shared File" instead of "Local File". This dialog is a little confusing. The line next to "Shared File" can only be a path, not a file name - and it defaults to the root path of the current project. Once you hit "Apply", a file named the [Run Configuration Name] + ".launch" is created within that folder. E.g., this results in a "/JavaTest/TransformingLibrary.launch" file. This is something that can be committed to version control.