Skip to content

Setting up Eclipse

Dave Parker edited this page Feb 10, 2022 · 11 revisions

It should be relatively straightforward to set up Eclipse to work with the PRISM code base (much of the development of PRISM is done within Eclipse). Proceed as follows:

Compiling the code

  • If you haven't done so already, get the PRISM source code. The easiest way to do this is to clone the main repo: https://github.com/prismmodelchecker/prism

  • Build PRISM from the command line before you import into Eclipse. This is to get the C/C++ code built, which won't be compiled by Eclipse. This should just require you to cd into the prism subdirectory and run make. See the installation instructions if you have problems.

  • Now, create a new Java project in Eclipse, choosing to use the existing PRISM directory rather than creating a new one (untick "Use default location" in recent versions of Eclipse). It's best to use the top-level PRISM directory (i.e., one level up from the prism subdirectory where you ran make), so that you have access to the examples repository and other useful files. These instructions assume that you do so, but it's also possible to use the prism subdirectory if you prefer. Either way, Eclipse will read the PRISM .classpath file, which specifies the list of required jar files (in prism/lib), and specifies where PRISM expects compiled code to be put (in prism/classes).

  • You probably now want to re-compile PRISM's Java code using Eclipse (select "Project | Clean...") to check that everything is working and to make sure that the code gets compiled with debugging info.

Running the code

  • If you want to run/debug PRISM from PRISM, there are a few more steps. Create a new "Java Application" item from the "Run Configuration" dialog and set up the following:

    • Main class: Use prism.PrismCL for command-line PRISM or userinterface.GUIPrism for the GUI.

    • Dependencies (classpath): You should already have the necessary jar files set up because Eclipse reads these from the existing .classpath file when you create the project. If you want to run the GUI from Eclipse, you'll need to add the prism subdirectory (from "Advanced... | Add Folders") so that icons/images are found at run-time.

    • Environment: Create a new environment variable whose name is LD_LIBRARY_PATH (on Linux) or DYLD_LIBRARY_PATH (on Mac) or PATH (on Windows) and whose value is prism/lib. Make sure "Append environment to native environment" is selected (it should be by default). This will allow Eclipse to find PRISM's native shared libraries (through JNI at runtime). This assumes that you use the top-level directory as a working directory at runtime. If you prefer to use the prism subdirectory (either by creating the project there, or by setting the working directory for the run configuration), use lib instead for the environment variable.

    • VM arguments: It is usually not necessary, but if you see UnsatisfiedLinkError errors even with the above settings, try also setting "VM arguments" in the run configuration to -Djava.library.path=prism/lib.

Code formatting

If you use Eclipse's code formatting functionality and want to write Java code that is consistent in style with PRISM, you can use our Eclipse configuration file. Go to "Java | Code Style | Formatting" in the Eclipse preferences, click "Import..." and then select the file prism-eclipse-formatter.xml which can be found in the prism/etc directory of PRISM source distributions.