In this tutorial, you will learn how to successfully run the LuciadLightspeed samples from Eclipse.

Prerequisites for the IDE integration

In the project configuration procedure, it is assumed that you already installed the following software:

Creating a Luciadlightspeed development project in Eclipse

  1. Start Eclipse, and accept the suggested workspace location in the Eclipse Launcher by clicking OK.

    You won’t need the default Eclipse workspace to set up a LuciadLightspeed development project.

  2. From the main menu, select File > New > Java Project. The New Java Project screen opens.

  3. De-select the Use default location check box, and in the Location field, browse to the root directory of your LuciadLightspeed installation. Once you select that location, Eclipse automatically fills in the Project name field.

    definejavaproject
  4. Click Finish. Eclipse sets up your project.

Completing the project configuration

Before you can run the samples, you need to make sure that all project dependencies are in place, such as the LuciadLightspeed libraries, license file, and project resources. It is also strongly recommended to enable annotation processing in your project. LuciadLightspeed uses annotations to register services with a registry, so that it can provide instant application services.

Defining the project libraries

  1. In the Package Explorer pane on the left, right-click the project you just created, and select Properties from the context menu.

  2. In the project Properties window, go to Java Build Path > Libraries, and remove all the JARs and class folders in the overview (Ctrl + A to select all content, and click Remove).

    clearlibrariestab
  3. Set the project build path up from scratch, and add all required libraries manually:

    1. To add the Java JRE you want to use, click Add Library…​, select JRE System Library from the library types, and click Next. You can select the default workspace JRE or browse for an alternate JRE. Make sure that you select a version 8 JRE, for example the JRE that you installed with the prerequisite JDK. Click Finish to add the selected JRE.

      selectlibrarytypejre
      jresystemlibrary
    2. To add the LuciadLightspeed library, click Add Library…​. Then select User Library from the library types, and click Next.

      selectuserlibrary
    3. In the Add Library window, click the User Libraries…​ button to start the defining the contents of the LuciadLightspeed library

    4. In the Preferences | User Libraries pane, click New, and enter a library name that includes LuciadLightspeed and the version number, and click OK.

      definellsuserlibrary

    5. Still in the Preferences | User Libraries pane, click Add JARs…​. In the JAR selection window, select all JAR files in the lib directory of your LuciadLightspeed installation, and click OK.

      selectjarsllslibrary

      Your LuciadLightspeed library is now visible in the Preferences | User Libraries pane.

      llslibrarydefinitionresult
    6. Click Apply and Close. Make sure the library is selected in the Add Library window, and click Finish.

      selectllslibrary
    7. In the Java Build Path | Libraries pane, click the Add Class Folder…​ button.

    8. In the Class Folder Selection window, select the config and samples/resources folders, and click OK.

      resourceselection
    9. Back on the Libraries tab of the project Properties window, click Add JARs…​. In the JAR selection window, select the LuciadLightspeed license file (development.jar), and click OK. The license file typically resides in the licenses folder. After the addition of the license file, the Libraries tab looks like this:

      buildpathlibrariesresult
  4. Click the Apply button to commit all changes. Eclipse now knows which files and folders to use to configure the project.

Defining the location of the sources

  1. In the project Properties window, go to Java Build Path > Source.

  2. Select every source folder in the list, except the samples/src folder, and click the Remove button.

    buildpathsourceresult
  3. Click the Apply button to apply your changes to the project. This may take a couple of minutes.

Configuring the Java compiler for Java compliance and annotation processing

  1. In the project Properties window, go to Java Compiler, and select the Enable project specific settings check box.

  2. In the Compiler compliance level drop-down menu, select 1.8. Make sure that the selected compliance level matches the JDK/JRE you are using.

    compilercompliance
  3. Still in the Properties window, go to Java Compiler > Annotation Processing, and select the Enable project specific settings check box.

  4. Select the Enable annotation processing check box.

  5. Expand Annotation Processing in the property navigation pane on the left, and select Factory Path. In the Factory Path pane, select the Enable project specific settings check box.

  6. Click Add JARs, and select lcd_annotations.jar from the lib folder in the JAR Selection window, and click OK. The selected file contains the annotations definition.

    runfactoryaddannotations
  7. Click Apply and Close, and confirm that you want to rebuild the project by clicking Yes in the Annotation Processing Settings Changed dialog box. Eclipse re-builds your project. This may take a couple of minutes.

Defining a run configuration for the LuciadLightspeed samples

Luciad strongly recommends specifying a number of Virtual Machine (VM) options before running your samples. They will ensure that your samples run smoothly, and perform well. You can specify the VM options in the run configuration for a sample in your LuciadLightspeed project.

  1. Select the main class of the sample in the samples/src folder, and go to Run > Run Configurations.

  2. In the Run Configurations window, select Java Application in the navigation pane on the left, and click the New launch configuration button.

  3. Specify an appropriate name for the run configuration.

  4. Go to the Arguments tab, and copy the VM options below into the VM arguments field, and click Run.

    -Xmx750m
    -Djava.net.useSystemProxies=true
    -XX:+CMSParallelRemarkEnabled
    -Dsun.awt.noerasebackground=true
    -Dsun.java2d.opengl=false
    -Dswing.aatext=true
    -Dsun.java2d.noddraw=true
    -Djava.library.path=

    For Java 1.8 versions, you should also specify these options:

    -XX:+UseConcMarkSweepGC
    -XX:+CMSParallelRemarkEnabled

    To run JavaFX samples on Java 11 or higher, you should also specify these options:

    --add-modules javafx.controls,javafx.web,javafx.swing
    --module-path /path/to/your/javafx-sdk/lib
    runconfigvmarguments

    If you are using a 64-bit Java VM, you can increase the XMX option to even higher values.

    Your sample now runs with the recommended VM options. Go to the Run runbutton button in the main toolbar. Select the run configuration you just defined from the drop-down menu.

    You can specify a generic VM parameter configuration for all project applications by going to Window > Preferences > Java > Installed JREs. Select the appropriate JRE, and add all the VM arguments to the Default VM arguments text box. As a result, you can simply select Java application as your run configuration for each sample.

You are done! You can now run samples and start developing.

Integrating the LuciadLightspeed Javadoc into your project

Eclipse can show you the Javadoc for a LuciadLightspeed API code element when you select and hover over the element. To activate the hover feature for the LuciadLightspeed Javadoc:

  1. In the Package Explorer pane on the left, right-click the project, and select Properties from the context menu.

  2. In the project Properties window, go to Java Build Path > Libraries, and expand the LuciadLightspeed user library you created earlier.

    addjavadoc1
  3. Expand the entry of each of the lcd_*.jar files for which you want to see Javadoc.

    addjavadoc2
  4. Select Javadoc location: and click Edit.

  5. In the Javadoc For window, click the Browse button next to the Javadoc location path: text field.

    addjavadoc3
  6. Navigate to the docs/reference/LuciadLightspeed directory in the LuciadLightspeed installation directory, select it, and click OK.

    Click OK to close the window, and then Apply and Close to finish the Javadoc setup in the project Properties window. The LuciadLightspeed library Javadoc is now visible when you hover over a code element.

Test running a sample

You can test your IDE setup by running the shapes example in the samples/src directory:

  1. Select samples.lightspeed.shapes in the samples/src folder in the Package Explorer pane on the left.

  2. Go to the Run runbutton button in the main toolbar, and select the run configuration you set up. The sample starts in this window.

    runningsample

You can now look at the code, modify it, or start developing your own application.