java +vtk.jar+dlls,环境部署配置遇到的问题

2023-12-20 03:58

本文主要是介绍java +vtk.jar+dlls,环境部署配置遇到的问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1、Java版本的vtk编译成功后会产生两种文件(2种不是2个):

一个vtk.jar文件

多个.dll文件



2、本地配置部署vtk+java 环境

讲所有的.dll文件复制到jdk安装目录下的bin目录里面,(和javaw.exe文件在同一个文件夹下)

项目中导入vtk.jar包

运行demo即可成功

如果没有成功,检查本地是否安装了vs

如果本地电脑没有安装过或没有安装Visual Studio 2017或者其他版本的Visual Studio,则很有可能会运行不成功,此时就需要安装Visual Studio 2017,原因我猜测可能是VTK在运行时可能需要依赖VS安装的某些相关组件,具体原因不明,经过我的实践发现的确安装了vs之后,demo可以正常运行。

(建议安装与编译工具VS一样的版本,比较靠谱点)



eg:

我的jdk安装的是1.7,安装目录是C:\Program Files\Java\jdk1.7.0_75

所有的dll文件需要复制到C:\Program Files\Java\jdk1.7.0_75\bin目录下

新建测试项目Java project,然后在项目中build panth,导入vtk.jar包

运行测试demo,成功

测试项目目录:


测试demo:

/*public class cone {*//*** @param args*//*public static void main(String[] args) {// TODO Auto-generated method stub}}*/
//
//This example creates a polygonal model of a cone, and then renders it to  
//the screen. It will rotate the cone 360 degrees and then exit. The basic  
//setup of source -> mapper -> actor -> renderer -> renderwindow is   
//typical of most VTK programs.  
////We import the vtk wrapped classes first.  
import vtk.*;  //Then we define our class.  
public class Cone { static {if (!vtkNativeLibrary.LoadAllNativeLibraries()) {for (vtkNativeLibrary lib : vtkNativeLibrary.values()) {if (!lib.IsLoaded()) {System.out.println(lib.GetLibraryName() + " not loaded");}}}vtkNativeLibrary.DisableOutputWindow(null);}// In the static contructor we load in the native code.  
// The libraries must be in your path to work.  
//static {   
//System.loadLibrary("vtkCommonJava");   
//System.loadLibrary("vtkFilteringJava");   
//System.loadLibrary("vtkIOJava");   
//System.loadLibrary("vtkImagingJava");   
//System.loadLibrary("vtkGraphicsJava");   
//System.loadLibrary("vtkRenderingJava");   
//}  // now the main program  
public static void main (String []args) {  
//   
// Next we create an instance of vtkConeSource and set some of its  
// properties. The instance of vtkConeSource "cone" is part of a  
// visualization pipeline (it is a source process object); it produces data  
// (output type is vtkPolyData) which other filters may process.  
//  
vtkConeSource cone = new vtkConeSource();  
cone.SetHeight( 3.0 );  
cone.SetRadius( 1.0 );  
cone.SetResolution( 10 );  //   
// In this example we terminate the pipeline with a mapper process object.  
// (Intermediate filters such as vtkShrinkPolyData could be inserted in  
// between the source and the mapper.)  We create an instance of  
// vtkPolyDataMapper to map the polygonal data into graphics primitives. We  
// connect the output of the cone souece to the input of this mapper.  
//  
vtkPolyDataMapper coneMapper = new vtkPolyDataMapper();  
coneMapper.SetInputConnection( cone.GetOutputPort() );  //   
// Create an actor to represent the cone. The actor orchestrates rendering  
// of the mapper's graphics primitives. An actor also refers to properties  
// via a vtkProperty instance, and includes an internal transformation  
// matrix. We set this actor's mapper to be coneMapper which we created  
// above.  
//  
vtkActor coneActor = new vtkActor();  
coneActor.SetMapper( coneMapper );  //  
// Create the Renderer and assign actors to it. A renderer is like a  
// viewport. It is part or all of a window on the screen and it is  
// responsible for drawing the actors it has.  We also set the background  
// color here  
//  
vtkRenderer ren1 = new vtkRenderer();  
ren1.AddActor( coneActor );  
ren1.SetBackground( 0.1, 0.2, 0.4 );  //  
// Finally we create the render window which will show up on the screen  
// We put our renderer into the render window using AddRenderer. We also  
// set the size to be 300 pixels by 300  
//  
vtkRenderWindow renWin = new vtkRenderWindow();  
renWin.AddRenderer( ren1 );  
renWin.SetSize( 300, 300 );  //  
// now we loop over 360 degreeees and render the cone each time  
//  
int i;  
for (i = 0; i < 360; ++i)  {  // render the image  renWin.Render();  // rotate the active camera by one degree  ren1.GetActiveCamera().Azimuth( 1 );  }  }   
}  
import vtk.*;//Then we define our class.
public class Cylinder {// In the static contructor we load in the native code.
// The libraries must be in your path to work.static {if (!vtkNativeLibrary.LoadAllNativeLibraries()) {for (vtkNativeLibrary lib : vtkNativeLibrary.values()) {if (!lib.IsLoaded()) {System.out.println(lib.GetLibraryName() + " not loaded");}}}vtkNativeLibrary.DisableOutputWindow(null);}// now the main program
public static void main (String []args) {vtkCylinderSource cylinder = new vtkCylinderSource();cylinder.SetResolution( 8 );vtkPolyDataMapper cylinderMapper = new vtkPolyDataMapper();cylinderMapper.SetInputConnection( cylinder.GetOutputPort() );vtkActor cylinderActor = new vtkActor();cylinderActor.SetMapper( cylinderMapper );cylinderActor.GetProperty().SetColor(1.0000, 0.3882, 0.2784);cylinderActor.RotateX(30.0);cylinderActor.RotateY(-45.0);vtkRenderer ren = new vtkRenderer();vtkRenderWindow renWin = new vtkRenderWindow();renWin.AddRenderer( ren );ren.AddActor( cylinderActor );vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();iren.SetRenderWindow(renWin);ren.AddActor(cylinderActor);ren.SetBackground(0.1, 0.2, 0.4);renWin.SetSize(200, 200);iren.Initialize();ren.ResetCamera();ren.GetActiveCamera().Zoom(1.5);renWin.Render();iren.Start();}
}

测试结果:



4、遇到的问题

一、问题1

java.lang.UnsatisfiedLinkError: C:\Program Files\Java\jdk1.7.0_75\bin\vtkChartsCoreJava.dll: Can't find dependent libraries

。。。。。。

解决方法:

未安装VS2017,安装了之后即可成功运行

(PS:因为我调用的vtk.jar包和dll文件都是从VS2017编译得到的,所以需要安装这个版本的VS,如果你用的是其他版本的VS编译得到的vtkjar包和dll文件,则需要安装对应版本的vs)


二、问题2

解决方法:

原因是项目默认的jdk是自带的jdk1.6,而我的dll文件是配置给了jdk1.7的bin目录,

所以显示找不到指定程序

所以,2种方法:

1.给jdk1.6配一下dll。需要把dll文件载复制一份到对应的jdk1.6的bin目录下即可

2.把项目的jdk换成1.7即可


5、相关资源

VTK8.0.1+VS2017+Cmake3+64位机器

编译后的必须文件dll+jar文件

获取资源:https://download.csdn.net/download/sinat_23619409/10340863

这篇关于java +vtk.jar+dlls,环境部署配置遇到的问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/514690

相关文章

Android 12解决push framework.jar无法开机的方法小结

《Android12解决pushframework.jar无法开机的方法小结》:本文主要介绍在Android12中解决pushframework.jar无法开机的方法,包括编译指令、框架层和s... 目录1. android 编译指令1.1 framework层的编译指令1.2 替换framework.ja

MySQL主从同步延迟问题的全面解决方案

《MySQL主从同步延迟问题的全面解决方案》MySQL主从同步延迟是分布式数据库系统中的常见问题,会导致从库读取到过期数据,影响业务一致性,下面我将深入分析延迟原因并提供多层次的解决方案,需要的朋友可... 目录一、同步延迟原因深度分析1.1 主从复制原理回顾1.2 延迟产生的关键环节二、实时监控与诊断方案

SpringBoot中四种AOP实战应用场景及代码实现

《SpringBoot中四种AOP实战应用场景及代码实现》面向切面编程(AOP)是Spring框架的核心功能之一,它通过预编译和运行期动态代理实现程序功能的统一维护,在SpringBoot应用中,AO... 目录引言场景一:日志记录与性能监控业务需求实现方案使用示例扩展:MDC实现请求跟踪场景二:权限控制与

Android开发环境配置避坑指南

《Android开发环境配置避坑指南》本文主要介绍了Android开发环境配置过程中遇到的问题及解决方案,包括VPN注意事项、工具版本统一、Gerrit邮箱配置、Git拉取和提交代码、MergevsR... 目录网络环境:VPN 注意事项工具版本统一:android Studio & JDKGerrit的邮

SQLyog中DELIMITER执行存储过程时出现前置缩进问题的解决方法

《SQLyog中DELIMITER执行存储过程时出现前置缩进问题的解决方法》在SQLyog中执行存储过程时出现的前置缩进问题,实际上反映了SQLyog对SQL语句解析的一个特殊行为,本文给大家介绍了详... 目录问题根源正确写法示例永久解决方案为什么命令行不受影响?最佳实践建议问题根源SQLyog的语句分

Java NoClassDefFoundError运行时错误分析解决

《JavaNoClassDefFoundError运行时错误分析解决》在Java开发中,NoClassDefFoundError是一种常见的运行时错误,它通常表明Java虚拟机在尝试加载一个类时未能... 目录前言一、问题分析二、报错原因三、解决思路检查类路径配置检查依赖库检查类文件调试类加载器问题四、常见

Java注解之超越Javadoc的元数据利器详解

《Java注解之超越Javadoc的元数据利器详解》本文将深入探讨Java注解的定义、类型、内置注解、自定义注解、保留策略、实际应用场景及最佳实践,无论是初学者还是资深开发者,都能通过本文了解如何利用... 目录什么是注解?注解的类型内置注编程解自定义注解注解的保留策略实际用例最佳实践总结在 Java 编程

gradle第三方Jar包依赖统一管理方式

《gradle第三方Jar包依赖统一管理方式》:本文主要介绍gradle第三方Jar包依赖统一管理方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录背景实现1.顶层模块build.gradle添加依赖管理插件2.顶层模块build.gradle添加所有管理依赖包

解决IDEA报错:编码GBK的不可映射字符问题

《解决IDEA报错:编码GBK的不可映射字符问题》:本文主要介绍解决IDEA报错:编码GBK的不可映射字符问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录IDEA报错:编码GBK的不可映射字符终端软件问题描述原因分析解决方案方法1:将命令改为方法2:右下jav

Java 实用工具类Spring 的 AnnotationUtils详解

《Java实用工具类Spring的AnnotationUtils详解》Spring框架提供了一个强大的注解工具类org.springframework.core.annotation.Annot... 目录前言一、AnnotationUtils 的常用方法二、常见应用场景三、与 JDK 原生注解 API 的