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

相关文章

Java 正则表达式URL 匹配与源码全解析

《Java正则表达式URL匹配与源码全解析》在Web应用开发中,我们经常需要对URL进行格式验证,今天我们结合Java的Pattern和Matcher类,深入理解正则表达式在实际应用中... 目录1.正则表达式分解:2. 添加域名匹配 (2)3. 添加路径和查询参数匹配 (3) 4. 最终优化版本5.设计思

Java使用ANTLR4对Lua脚本语法校验详解

《Java使用ANTLR4对Lua脚本语法校验详解》ANTLR是一个强大的解析器生成器,用于读取、处理、执行或翻译结构化文本或二进制文件,下面就跟随小编一起看看Java如何使用ANTLR4对Lua脚本... 目录什么是ANTLR?第一个例子ANTLR4 的工作流程Lua脚本语法校验准备一个Lua Gramm

Java字符串操作技巧之语法、示例与应用场景分析

《Java字符串操作技巧之语法、示例与应用场景分析》在Java算法题和日常开发中,字符串处理是必备的核心技能,本文全面梳理Java中字符串的常用操作语法,结合代码示例、应用场景和避坑指南,可快速掌握字... 目录引言1. 基础操作1.1 创建字符串1.2 获取长度1.3 访问字符2. 字符串处理2.1 子字

Java Optional的使用技巧与最佳实践

《JavaOptional的使用技巧与最佳实践》在Java中,Optional是用于优雅处理null的容器类,其核心目标是显式提醒开发者处理空值场景,避免NullPointerExce... 目录一、Optional 的核心用途二、使用技巧与最佳实践三、常见误区与反模式四、替代方案与扩展五、总结在 Java

Linux内核参数配置与验证详细指南

《Linux内核参数配置与验证详细指南》在Linux系统运维和性能优化中,内核参数(sysctl)的配置至关重要,本文主要来聊聊如何配置与验证这些Linux内核参数,希望对大家有一定的帮助... 目录1. 引言2. 内核参数的作用3. 如何设置内核参数3.1 临时设置(重启失效)3.2 永久设置(重启仍生效

基于Java实现回调监听工具类

《基于Java实现回调监听工具类》这篇文章主要为大家详细介绍了如何基于Java实现一个回调监听工具类,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录监听接口类 Listenable实际用法打印结果首先,会用到 函数式接口 Consumer, 通过这个可以解耦回调方法,下面先写一个

IDEA自动生成注释模板的配置教程

《IDEA自动生成注释模板的配置教程》本文介绍了如何在IntelliJIDEA中配置类和方法的注释模板,包括自动生成项目名称、包名、日期和时间等内容,以及如何定制参数和返回值的注释格式,需要的朋友可以... 目录项目场景配置方法类注释模板定义类开头的注释步骤类注释效果方法注释模板定义方法开头的注释步骤方法注

使用Java将DOCX文档解析为Markdown文档的代码实现

《使用Java将DOCX文档解析为Markdown文档的代码实现》在现代文档处理中,Markdown(MD)因其简洁的语法和良好的可读性,逐渐成为开发者、技术写作者和内容创作者的首选格式,然而,许多文... 目录引言1. 工具和库介绍2. 安装依赖库3. 使用Apache POI解析DOCX文档4. 将解析

Java字符串处理全解析(String、StringBuilder与StringBuffer)

《Java字符串处理全解析(String、StringBuilder与StringBuffer)》:本文主要介绍Java字符串处理全解析(String、StringBuilder与StringBu... 目录Java字符串处理全解析:String、StringBuilder与StringBuffer一、St

springboot整合阿里云百炼DeepSeek实现sse流式打印的操作方法

《springboot整合阿里云百炼DeepSeek实现sse流式打印的操作方法》:本文主要介绍springboot整合阿里云百炼DeepSeek实现sse流式打印,本文给大家介绍的非常详细,对大... 目录1.开通阿里云百炼,获取到key2.新建SpringBoot项目3.工具类4.启动类5.测试类6.测