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

相关文章

Kotlin Map映射转换问题小结

《KotlinMap映射转换问题小结》文章介绍了Kotlin集合转换的多种方法,包括map(一对一转换)、mapIndexed(带索引)、mapNotNull(过滤null)、mapKeys/map... 目录Kotlin 集合转换:map、mapIndexed、mapNotNull、mapKeys、map

MySQL 主从复制部署及验证(示例详解)

《MySQL主从复制部署及验证(示例详解)》本文介绍MySQL主从复制部署步骤及学校管理数据库创建脚本,包含表结构设计、示例数据插入和查询语句,用于验证主从同步功能,感兴趣的朋友一起看看吧... 目录mysql 主从复制部署指南部署步骤1.环境准备2. 主服务器配置3. 创建复制用户4. 获取主服务器状态5

nginx中端口无权限的问题解决

《nginx中端口无权限的问题解决》当Nginx日志报错bind()to80failed(13:Permissiondenied)时,这通常是由于权限不足导致Nginx无法绑定到80端口,下面就来... 目录一、问题原因分析二、解决方案1. 以 root 权限运行 Nginx(不推荐)2. 为 Nginx

SpringBoot中六种批量更新Mysql的方式效率对比分析

《SpringBoot中六种批量更新Mysql的方式效率对比分析》文章比较了MySQL大数据量批量更新的多种方法,指出REPLACEINTO和ONDUPLICATEKEY效率最高但存在数据风险,MyB... 目录效率比较测试结构数据库初始化测试数据批量修改方案第一种 for第二种 case when第三种

解决1093 - You can‘t specify target table报错问题及原因分析

《解决1093-Youcan‘tspecifytargettable报错问题及原因分析》MySQL1093错误因UPDATE/DELETE语句的FROM子句直接引用目标表或嵌套子查询导致,... 目录报js错原因分析具体原因解决办法方法一:使用临时表方法二:使用JOIN方法三:使用EXISTS示例总结报错原

Java docx4j高效处理Word文档的实战指南

《Javadocx4j高效处理Word文档的实战指南》对于需要在Java应用程序中生成、修改或处理Word文档的开发者来说,docx4j是一个强大而专业的选择,下面我们就来看看docx4j的具体使用... 目录引言一、环境准备与基础配置1.1 Maven依赖配置1.2 初始化测试类二、增强版文档操作示例2.

一文详解如何使用Java获取PDF页面信息

《一文详解如何使用Java获取PDF页面信息》了解PDF页面属性是我们在处理文档、内容提取、打印设置或页面重组等任务时不可或缺的一环,下面我们就来看看如何使用Java语言获取这些信息吧... 目录引言一、安装和引入PDF处理库引入依赖二、获取 PDF 页数三、获取页面尺寸(宽高)四、获取页面旋转角度五、判断

Windows环境下解决Matplotlib中文字体显示问题的详细教程

《Windows环境下解决Matplotlib中文字体显示问题的详细教程》本文详细介绍了在Windows下解决Matplotlib中文显示问题的方法,包括安装字体、更新缓存、配置文件设置及编码調整,并... 目录引言问题分析解决方案详解1. 检查系统已安装字体2. 手动添加中文字体(以SimHei为例)步骤

Spring Boot中的路径变量示例详解

《SpringBoot中的路径变量示例详解》SpringBoot中PathVariable通过@PathVariable注解实现URL参数与方法参数绑定,支持多参数接收、类型转换、可选参数、默认值及... 目录一. 基本用法与参数映射1.路径定义2.参数绑定&nhttp://www.chinasem.cnbs

JAVA中安装多个JDK的方法

《JAVA中安装多个JDK的方法》文章介绍了在Windows系统上安装多个JDK版本的方法,包括下载、安装路径修改、环境变量配置(JAVA_HOME和Path),并说明如何通过调整JAVA_HOME在... 首先去oracle官网下载好两个版本不同的jdk(需要登录Oracle账号,没有可以免费注册)下载完