Setting up Eclipse

From gvSIG CE Wiki

Jump to: navigation, search

The principle Java development environment for gvSIG CE is Eclipse. On this page we will show you how set up a basic Eclipse development environment for being able to check out the gvSIG CE sources from the SVN and compile them.

These instructions have been compiled based on Eclipse version 4.3. Some steps may vary for more recent or older versions of Eclipse.

Contents

Downloading Eclipse

If you don't have it yet, then download and install Eclipse from its project home page.

Eclipse supports much more than just Java coding, and there are many different Eclipse packages offered for download that support different features out-of-the-box. Just download the "Classic" package. Eclipse comes as a ZIP archive that needs no further installation. Just unpack it somewhere and run the Eclipse executable.

Whatever version of Eclipse you get, you can always add more needed features later using via "Help > Install New Software...". Also, when installing mandatory extensions, such as the SVN client (see below), Eclipse is capable of downloading and installing any additional needed features automatically.

Linux users: Eclipse is a complex system and the packaged version for your distribution may be less than ideal. If you experience strange behavior (such as Java compilation producing "MANIFEST only" files), the best solution may be to scrap your distribution's version of Eclipse and install the software manually, from its official homepage, into your home directory.

Setting up your workspace

When you first run it, Eclipse will ask you for a default workspace to use. This is just a folder on your disk which you will use to download all the gvSIG CE source code and work with it. Choose any folder you like. But remember that this will contain all your precious work and configurations, so making your own personal backup copies from time to time may not be a bad idea, even if you plan to commit all your code changes back to the SVN.

The gvSIG sources have been written mostly by Spanish developers and contain accent characters. It is therefore necessary to set up the correct text encoding for your workspace:

  1. Go to "Window > Preferences" to open the main preferences window.
  2. Unfold the "General" branch of the settings tree (click on the little "+") and select the "Workspace" page.
  3. Under "Text Encoding", select "(o) Other" and switch the selection to "UTF-8".

Setting up the Java Development Kit (JDK)

The gvSIG CE sources are optimized for Java 7 (more precisely: OpenJDK 1.7). We recommend you install OpenJDK 7 (http://openjdk.java.net) and configure Eclipse to use that version. Most major Linux distribution should now ship with OpenJDK in their repositories. The minimum version of Mac OS X required to run Java 7 is 10.7.3.

If wish to download a set of binaries and install them locally, then you should be able to find the right version for your system here.

Downloading and installing the JDK

Note that you can have any number of JDKs installed on your system. They will not interfere with each other, as long as you configure Eclipse correctly.

If your operating system does not ship with OpenJDK7 or you want to use your own, isolated JDK, then the easiest option is to download a binary distribution of OpenJDK 7 for your system.

In addition, gvSIG CE requires two additional Java class libraries for efficient raster data handling: Java Advanced Imaging (JAI) and Java Image I/O (see also here).

Important: We recommend you install a "pure Java" version of both libraries, as described on our page about Java Advanced Imaging (JAI) and 64 bit. For 64 bit Windows users, there is no other way to get JAI on their systems! Only follow the instructions below if you are on 32/64 bit Linux or 32 bit Windows and really want the extra speed that the native binaries version of JAI might provide.

  1. Go to the JAI download page.
  2. You will find installation instructions and download packages for your operating system there. Make sure to download the "jdk" variant, as you need this for development purposes.
  3. Read the INSTALL.html link on the page above for installation instructions. Make sure to install the JAI into the correct JDK path.
  4. Go to the JAI Image I/O page.
  5. Again, download packages and installation instructions for your system can be found on that page. Proceed as for the JAI.

Note: on some Linux systems, an error message similar to this will appear when attempting to install using the .bin file:

 tail: cannot open `+215' for reading: No such file or directory

The fix is to run this command before executing the installer:

 export _POSIX2_VERSION=199209

Another solution to fix this error is explained here Grass Tech Tips because sometimes the export solution does not work

Note: Eclipse should be able to automatically detect the JAI classes inside the JDK tree and allow all projects in the workspace to link against them. However, this process may fail and you will get "unresolved dependency" errors on javax.media.JAI.jai from the Java compiler. In that case, open the Eclipse preferences ("Window->Preferences"), go to the "Java/Installed JREs" and "Edit..." your active JRE. In the "JRE Definition" window, remove the references to "jai_codec.jar", "jai_core.jar" and "jai_imageio.jar", then click "Finish". Finally, open the "Edit..." window once more and re-add the references that you just deleted. Then press "Finish" againg. This should fully update the class path of your current JRE/JDK.

Setting up the JDK in Eclipse

Now you will need to tell Eclipse to use the JDK you just set up.

  1. From the Eclipse main menu bar, choose "Window -> Preferences".
  2. Open the category "Java".
  3. Go to "Compiler" and make sure that the "Compiler compliance level" is set to "1.6".
  4. Go to "Installed JREs" and click "Add".
  5. The window "Add JRE" will come up. Select "Standard VM" and click "Next >"-
  6. Under "JRE Home", Select your JDK path and click "Finish". Your personal JDK will be added to the list of installed JREs.
  7. Tick the box "[x]" to the left of it so that it will be used as the default JRE.
  8. Click "OK".

Windows users: Eclipse will probably auto-detect your system-wide JRE if you have one. Make sure to change this to actually point to the JDK you are using for development. If your use a system-wide JDK: you will find it in the same folder as the system's JRE.

Installing the SVN plug-in

If your JDK does not include it yet, you have to install JavaHL (Java bindings for SVN) first. On Ubuntu, this is done using:

 sudo apt-get install libsvn-java

All other systems: please follow the instructions on this page to download and install JavaHL.

Then follow the installation instructions to install the client into Eclipse.

After the installation is complete, open the "Preferences" window from Eclipse's main menu.

Go to the page "Team -> SVN". This will allow you to configure the SVN plug-in:

  1. Make sure that "SVN interface" is set to "JavaHL".
  2. Go to "Console" and disable the option "Limit console output" (with this option enabled, Eclipse tends to hang on large SVN commit operations).

Next steps

You can now continue with Compiling the Java sources.