0

I have installed VTK for a physics simulation program called Starfish with its Github. But I am not asking for any physics help, but rather I am trying to add VTK as a library dependency to Starfish so that it can be run on Intellij.

Starfish is written in Java and when I installed VTK, and tried to add it in my IDE, but it doesn't work no matter what I do. The project throws: java: package vtk does not exist whenever I run the project's main or try to build it. The whole VTK dependency is not recognized. The VTK library is composed of dll type files and there are no JAR files for it. Also, there does not seem to be a Maven dependency for it as well, and Starfish is not a Maven project.

I have VTK version 9.2.2.

I have tried:

  1. Adding VTK as a module dependency under the project structure > project settings > modules > dependencies > choosing the path of the VTK installation

  2. Adding VTK as a library under project structure > project settings > libraries

  3. Adding the path to VTK /bin via -Djava.library.path="C:/path/to/VTK as a VM option in the run config of Intellij

  4. Adding VTK to the global libraries under project structure > Platform settings > global libraries

  5. Restarting and invalidating the cache

  6. Deleting the .idea directory and restarting

  7. Searching online for many days like stackoverflow, VTK forums, IntelliJ's forums, etc

I am out of ideas on what to try next. Any suggestions would be greatly appreciated. Thanks.

Compiler v2
  • 3,509
  • 10
  • 31
  • 55
  • One possible solution would be to create a JAR file containing the VTK library and then add that JAR file as a dependency to your project. – SANN3 Jan 22 '23 at 05:40
  • @SANN3 I created the jar file using https://stackoverflow.com/a/18146453/10821284 and then I added it to my project as a module and a library and even restarted, but it still doesn't recognize VTK. – Compiler v2 Jan 22 '23 at 18:04

1 Answers1

2

VTK is available as a Maven dependency. You can add Maven support for your project and include VTK in your pom.xml into dependencies section.

  • Right-click on a project root in Project View and select Add Framework Support... | Maven

  • Add the content below into pom.xml

    <repositories>
        <repository>
            <id>jzy3d-snapshots</id>
            <name>Jzy3d Snapshots</name>
            <url>https://maven.jzy3d.org/snapshots/</url>
        </repository>
        <repository>
            <id>jzy3d-releases</id>
            <name>Jzy3d Releases</name>
            <url>https://maven.jzy3d.org/releases/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.jzy3d</groupId>
            <artifactId>vtk-java-all</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
  • Click on Reload All Maven Projects in Maven tool window: enter image description here

Now imports to the VTK library should be resolved properly.

Egor Klepikov
  • 3,386
  • 5
  • 19
  • 34