当前位置: 首页 > news >正文

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

相关文章:

  • python安装numpy包教程等其他相关包
  • 解决pycharm无法调用pip安装的包
  • pycharm 2018 永久激活
  • 克里金(Kriging)插值的原理----反距离插值(IDW)
  • 克里金插值的定义----普通克里金插值算法
  • 期望和方差
  • 期望,方差,协方差计算法则
  • java jdbc连接mysql数据库实现增删改查操作
  • VTK地自定义8个点绘制立方体
  • VTKDemo:绘制线段、立方体、多条线段、管线:
  • 科学计算可视化相关包安装教程:vtk, numpy, traits, mayavi, pyqt,pyKriging,
  • VTK运行绘图结果出错,报JVM问题
  • 多态,覆盖,重载
  • 多线程:Java中实现多线程的两种方式之间的区别
  • 查看python已经安装的包
  • ES6指北【2】—— 箭头函数
  • [译]如何构建服务器端web组件,为何要构建?
  • 【comparator, comparable】小总结
  • CentOS学习笔记 - 12. Nginx搭建Centos7.5远程repo
  • HashMap剖析之内部结构
  • JSONP原理
  • js算法-归并排序(merge_sort)
  • php中curl和soap方式请求服务超时问题
  • 程序员最讨厌的9句话,你可有补充?
  • 机器学习学习笔记一
  • 漫谈开发设计中的一些“原则”及“设计哲学”
  • 前端 CSS : 5# 纯 CSS 实现24小时超市
  • 区块链将重新定义世界
  • 如何用Ubuntu和Xen来设置Kubernetes?
  • 手写一个CommonJS打包工具(一)
  • 小李飞刀:SQL题目刷起来!
  • 一起来学SpringBoot | 第三篇:SpringBoot日志配置
  • 原生JS动态加载JS、CSS文件及代码脚本
  • 在Docker Swarm上部署Apache Storm:第1部分
  • #QT(串口助手-界面)
  • #QT(智能家居界面-界面切换)
  • #我与Java虚拟机的故事#连载03:面试过的百度,滴滴,快手都问了这些问题
  • #我与Java虚拟机的故事#连载07:我放弃了对JVM的进一步学习
  • (7)STL算法之交换赋值
  • (iPhone/iPad开发)在UIWebView中自定义菜单栏
  • (k8s中)docker netty OOM问题记录
  • (阿里云万网)-域名注册购买实名流程
  • (六)激光线扫描-三维重建
  • (论文阅读30/100)Convolutional Pose Machines
  • (三) prometheus + grafana + alertmanager 配置Redis监控
  • (原創) 如何優化ThinkPad X61開機速度? (NB) (ThinkPad) (X61) (OS) (Windows)
  • *Algs4-1.5.25随机网格的倍率测试-(未读懂题)
  • .NET Framework Client Profile - a Subset of the .NET Framework Redistribution
  • .NET Standard / dotnet-core / net472 —— .NET 究竟应该如何大小写?
  • .NET 的静态构造函数是否线程安全?答案是肯定的!
  • .NET/C# 推荐一个我设计的缓存类型(适合缓存反射等耗性能的操作,附用法)
  • .Net+SQL Server企业应用性能优化笔记4——精确查找瓶颈
  • .net6解除文件上传限制。Multipart body length limit 16384 exceeded
  • .net获取当前url各种属性(文件名、参数、域名 等)的方法
  • .Net接口调试与案例