STK Java API - Configuring the Samples with the Eclipse IDE

The following instructions explain how to configure the STK Java API code samples provided in the STK install within the Eclipse Integrated Development Environment (IDE).

Note: On windows the code samples included in the STK install are read only. You must copy the appropriate directory (<STK install folder>\CodeSamples) to an area on the local machine where you have write permissions, and then mark the files writable before trying to compile them. Use the directory you chose instead of <STK install folder>\CodeSamples in the following instructions.

  1. Refer to the getting/installing Eclipse if you do not already have Eclipse installed on your machine. DO NOT create a new Eclipse Java application project.
  2. Start up the Eclipse IDE.
  3. When asked to select a Workspace, browse to the <STK install folder>\CodeSamples directory. Where <STK install folder> is the current release installation of STK / STK Engine.
  4. Click the OK button.

    Note: If the Eclipse IDE launches without displaying the above dialog, open the File menu and select Switch Workspace to display it, then browse to the above directory.

  5. Close the Eclipse IDE's Welcome screen.
  6. In Eclipse, left-click on the Window menu bar item.
  7. Left-click on the Preferences menu item.
  8. In the Preferences dialog, choose General -> Workspace -> Linked Resources.
  9. Left-click on the New... button.
  10. In the New Variable dialog, type JavaDevKit in the Name text field.
  11. Next left-click the Folder... button and in the folder selection dialog select your <STK_INSTALL_DIR>/bin folder and click the OK button.
  12. Choose one of the following to set up samples; otherwise, skip to step 13:
  13. From the File menu, select Import...
  14. In the Import dialog, open the General folder.
  15. Select Existing Projects into Workspace.
  16. Click the Next button.

  17. Choose Select root directory.
  18. Click the Browse button.
  19. Do NOT change the directory; instead, just click the OK button to dismiss the Browse for Folder dialog.

  20. Make certain that the projects shown in the image below are selected in the Projects area.

  21. Click the Finish button.
  22. By default most of the samples are pre-configured out of the box to begin to compile and start if STK was installed to the default location/settings and you have set up the workspace resources.
  23. Note that some projects will not compile, namely the STK_X_Eclipse_Plugin and STK_X_Eclipse_RCP. The errors in STK_X_Eclipse_Plugin and STK_X_Eclipse_RCP are because additional steps are required for their set-up.
  24. If you see any Samples with compilation error icons, check the following:
  25. If the errors are in all of the projects then check that the JavaDevKit Linked Resource is set to the correct directory.

    If the errors are only in the SWT projects then check that the SwtJar Linked Resource is set to the correct file.

    If the errors are only in the JavaFX projects then check that the JavaFXJar Linked Resource is set to the correct file.

    Open each project's properties and verify the Java Build Path does not have any unresolved errors.

  26. Click the Libraries tab, and note the jar libraries have a javadoc location are set to the default javadocs library. If not set properly, follow the steps in configuring an Eclipse project with the STK Java API javadoc intellisense.
  27. Tip: Some of the following steps may require editing of the project's Properties. Before performing such editing, you may want to make sure that the file is writable. See the section on Saving Project Settings at the end of this page.

  28. If you have changed any settings on the Properties page, click OK to save the settings and dismiss the page.
  29. Check to see if the samples have already been compiled. The Eclipse IDE automatically compiles Java files when they are added or changed within a project. Open the Project menu and see whether a check mark appears next to the Build Automatically item. If so, the samples have been compiled, and you can skip the next step.
  30. If the samples have not yet been compiled, then right-click on the current project you are working with in the Package Explorer and select Build Project.

Set .classpath file to writable if necessary for saving project settings

To make certain that you will be able to save any changes you make to the project's Properties page, find the .classpath file for the Eclipse project and verify that they are writable.

If you do not see the .classpath file in the Eclipse project directory...

  1. On Windows ...
  2. On Linux ...

STK Programming Interface 11.0.1