# VTK 9 and Java- vtk.jar not automatically generated. Also location of wrapper dlls

**URL:** https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354
**Category:** Support
**Created:** [May 20, 2020, 6:37pm UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354 "2020-05-20T18:37:25Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![eclrgp](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/e/e9a140/32.png) [@eclrgp](https://discourse.vtk.org/u/eclrgp)
#### Post date: [May 20, 2020, 6:37pm UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/1 "2020-05-20T18:37:25Z")

</div>

Using Visual Studio ( actually 2019 but I also have 2017) and using cmake 3.17.2 on Windows 10 1909  
The step to compile the java wrappers and build vtk.jar seems not to be run although the rest of the build happens. The .java files can be compiled manually and put into vtk.jar. The resulting jar file seems to work. The other problem I had was findjng the java wrapper dlls. These are put into  
\VTK-9.0.0\lib\java\vtk-Windows-AMD64 rather than in \VTK-9.0.0\bin\Release with the other dlls. Was the last change intentional?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [May 20, 2020, 7:10pm UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/2 "2020-05-20T19:10:54Z")

</div>

> [@eclrgp](#):
>
> The step to compile the java wrappers and build vtk.jar seems not to be run although the rest of the build happens

This appears to be a Visual Studio thing. Making jar files is not supported in it. The way it was done previously, every java file had a manual `javac` command associated with it and a following `jar` call later. This has been replaced with CMake’s Java support instead which is evidently not supported in Visual Studio. I recommend using the Ninja generator instead if you need Java builds working better on Windows.

> [@eclrgp](#):
>
> These are put into  
> \VTK-9.0.0\lib\java\vtk-Windows-AMD64 rather than in \VTK-9.0.0\bin\Release with the other dlls. Was the last change intentional?

Yes, they are only meant for use by the jar and are placed near it instead. This does likely mean that `PATH` is needed to use the jar on Windows, but install rules would need to be figured out anyways.

---

<div class="post-metadata">

### Author: ![eclrgp](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/e/e9a140/32.png) [@eclrgp](https://discourse.vtk.org/u/eclrgp)
#### Post date: [May 20, 2020, 9:13pm UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/3 "2020-05-20T21:13:20Z")

</div>

Thank you for the explanation. I just assumed the build process would work as it has done for previous versions. Actually all the hard work is done. vtk.jar can easily be built from the command line.  
I can see why it would be better to use CMake’s java support on platforms where it works.

---

<div class="post-metadata">

### Author: ![Daniel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/3ec8ea/32.png) [@Daniel](https://discourse.vtk.org/u/Daniel)
#### Post date: [July 22, 2020, 10:59am UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/4 "2020-07-22T10:59:21Z")

</div>

Hi,

that sounds good.  
@eclrgp, But how can I build ‘vtk.jar’ from the command line?

I also tried with Cmake and VS-2019. When I try the ninja generator, I get following error messages from Cmake:  
_No CMAKE\_C\_COMPILER could be found._  
_…_  
_No CMAKE\_CXX\_COMPILER could be found._  
_…_  
How can I set this?  
The PATH environment variable contains the following: _…\Gygwin\bin; …\ninja-win; \CMake\bin_ etc.  
Sorry, this way (with ninja generator) is new territory for me.

Any hint are welcome.  
Daniel

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [July 22, 2020, 3:16pm UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/5 "2020-07-22T15:16:58Z")

</div>

You need to use the developer prompt to get the MSVC environment loaded.

---

<div class="post-metadata">

### Author: ![eclrgp](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/e/e9a140/32.png) [@eclrgp](https://discourse.vtk.org/u/eclrgp)
#### Post date: [July 22, 2020, 4:19pm UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/6 "2020-07-22T16:19:59Z")

</div>

Hello Daniel,  
I have not used ninja and have kept to using VS.  
I assume you have configured cmake to include the java  
wrappers  
The VS cmake does not know how to build java files so the last  
stage of building the jar file has to be done manually since vtk  
9.0.0  
At a command prompt and assuming the source has been  
unpacked to \vtk-9.0.1

cd \vtk-9.0.1\Wrapping\Java  
dir /s/B _.java \>javafiles  
javac -d /vtk-9.0.1/java @javafiles  
cd \vtk-9.0.1\java  
jar --create -f …/bin/vtk.jar vtk/_.class

Ray

Date sent: Wed, 22 Jul 2020 10:59:22 +0000  
Send reply to: VTK [vtk+8b1cafcba92a11d2732025d7b1b9d26d@discourse.vtk.org](mailto:vtk+8b1cafcba92a11d2732025d7b1b9d26d@discourse.vtk.org)  
Also location of wrapper dlls

---

<div class="post-metadata">

### Author: ![Daniel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/3ec8ea/32.png) [@Daniel](https://discourse.vtk.org/u/Daniel)
#### Post date: [July 23, 2020, 9:05am UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/7 "2020-07-23T09:05:44Z")

</div>

Thank you very much, this looks very promising.  
I’ll try it out later and I’ll be in touch.

Daniel

---

<div class="post-metadata">

### Author: ![Daniel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/3ec8ea/32.png) [@Daniel](https://discourse.vtk.org/u/Daniel)
#### Post date: [July 24, 2020, 10:35am UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/8 "2020-07-24T10:35:55Z")

</div>

Hi there,

Something obviously went wrong.  
I have packed all .class files (with all subfolders) and folder META-INF (with MANIFEST.MF) into the vtk.jar.  
The folder of the created DLL files is specified in PATH.

When I start my program, all vtk-libraries are loaded first.

```
if (!vtkNativeLibrary.LoadAllNativeLibraries()) {
	for (vtkNativeLibrary lib : vtkNativeLibrary.values()) {
		if (!lib.IsLoaded()) {
			System.err.println(lib.GetLibraryName() + " not loaded");	notLoaded++;
		} else {
			System.out.println(" " + lib.GetLibraryName() + " was loaded!");	loaded++;
		}
		count++;
	}
	System.out.println(" --> N-files: " + count + " was: " + loaded + " NOT: " + notLoaded + " loaded.");
}

```

1.) Output is:  
…  
_–\> N-files: 102 was: 0 NOT: 102 loaded._  
…  
It seems that all DLL files are not found.

2.) But if I set PATH to the folder of the old DLL files and dont change the vtk.jar, I get the following output:  
_–\> N-files: 102 is: 89 NOT: 13 loaded._

At least other DLL files are also recognized here.

What went wrong? Any hints?

---

<div class="post-metadata">

### Author: ![eclrgp](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/e/e9a140/32.png) [@eclrgp](https://discourse.vtk.org/u/eclrgp)
#### Post date: [July 24, 2020, 11:47am UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/9 "2020-07-24T11:47:08Z")

</div>

Hello Daniel,  
Did you notice the other vtk dlls and java wrapper dlls are in  
different places  
\VTK-9.0.1\bin\Release  
or  
\VTK-9.0.1\bin\Debug

and

\VTK-9.0.1\lib\java\vtk-Windows-AMD64\Release  
or  
\VTK-9.0.1\lib\java\vtk-Windows-AMD64\Debug

Both sets of dlls need to be in the path

Ray

Date sent: Fri, 24 Jul 2020 10:35:56 +0000  
Send reply to: VTK  
\<[vtk+ae6c2104bc68c5805fcdfa1ff16b34a2@discourse.vtk.org](mailto:vtk+ae6c2104bc68c5805fcdfa1ff16b34a2@discourse.vtk.org)

> 

generated. Also  
location of wrapper dlls

> Hi there,  
> Something obviously went wrong.  
> I have packed all .class files (with all subfolders) and folder META-INF (with MANIFEST.MF) into  
> the vtk.jar.  
> The folder of the created DLL files is specified in PATH.  
> When I start my program, all vtk-libraries are loaded first.
> 
> if (!vtkNativeLibrary.LoadAllNativeLibraries()) {  
> for (vtkNativeLibrary lib : vtkNativeLibrary.values()) {  
> if (!lib.IsLoaded()) {  
> System.err.println(lib.GetLibraryName() + " not loaded"); notLoaded++;  
> } else {  
> System.out.println(" " + lib.GetLibraryName() + " was loaded!“); loaded++;  
> }  
> count++;  
> }  
> System.out.println(” → N-files: " + count + " was: " + loaded + " NOT: " + notLoaded + " loaded.");  
> }
> 
> 1.) Output is:  
> …  
> → N-files: 102 was: 0 NOT: 102 loaded.  
> …  
> It seems that all DLL files are not found.  
> 2.) But if I set PATH to the folder of the old DLL files and dont change the vtk.jar, I get the  
> following output:  
> → N-files: 102 is: 89 NOT: 13 loaded.  
> At least other DLL files are also recognized here.  
> What went wrong? Any hints?
> 
> Visit Topic or reply to this email to respond.  
> To unsubscribe from these emails, click here.

------- End of forwarded message -------

[WPM$V4NW.PM$](https://discourse.vtk.org/uploads/short-url/mSMMhM85vS9gTKzrnPcMe8niVuE.PM$) (1.95 KB)

---

<div class="post-metadata">

### Author: ![Daniel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/3ec8ea/32.png) [@Daniel](https://discourse.vtk.org/u/Daniel)
#### Post date: [July 24, 2020, 11:58am UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/10 "2020-07-24T11:58:41Z")

</div>

Thank you for pointing that out.  
I had forgotten the additional DLL files in the folder \VTK-9.0.1\lib\java\vtk-Windows-AMD64\Release .

---

<div class="post-metadata">

### Author: ![eclrgp](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/e/e9a140/32.png) [@eclrgp](https://discourse.vtk.org/u/eclrgp)
#### Post date: [July 24, 2020, 1:22pm UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/11 "2020-07-24T13:22:35Z")

</div>

Hello,  
I am beginning to run out of ideas.  
Do you set the property java.library.path  
either in your code or by supplying to the jvm by

-Djava.library.path=C:\VTK-9.0.1\bin\Release

Ray

Date sent: Fri, 24 Jul 2020 11:58:42 +0000  
Send reply to: VTK [vtk+92ce3a4c92caece67ce4f3fcf739aac8@discourse.vtk.org](mailto:vtk+92ce3a4c92caece67ce4f3fcf739aac8@discourse.vtk.org)  
Also location of wrapper dlls

> Daniel  
> July 24
> 
> Thank you for pointing that out.  
> I had forgotten the additional DLL files in the folder  
> \VTK-9.0.1\lib\java\vtk-Windows-AMD64\Release .  
> However, no file is loaded.  
> Output: → N-files: 102 is: 0 & NOT: 102 loaded.
> 
> Visit Topic or reply to this email to respond.
> 
> In Reply To
> 
> Ray Powell eclrgp  
> July 24
> 
> Hello Daniel, Did you notice the other vtk dlls and java wrapper dlls are in different places  
> \VTK-9.0.1\bin\Release or \VTK-9.0.1\bin\Debug and  
> \VTK-9.0.1\lib\java\vtk-Windows-AMD64\Release or  
> \VTK-9.0.1\lib\java\vtk-Windows-AMD64\Debug Both sets of dlls need to be in the path Ray Date  
> …
> 
> Visit Topic or reply to this email to respond.  
> To unsubscribe from these emails, click here.

Ray and Pamela Powell  
Phone: 0113 2550286

---

<div class="post-metadata">

### Author: ![Daniel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/3ec8ea/32.png) [@Daniel](https://discourse.vtk.org/u/Daniel)
#### Post date: [July 27, 2020, 7:50am UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/12 "2020-07-27T07:50:09Z")

</div>

Thanks for your help!!

I had already edited my post.  
It works now. In the end a space had sneaked into the PATH (of the vtk-dll files).

Daniel

---

<div class="post-metadata">

### Author: ![dporter](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dporter](https://discourse.vtk.org/u/dporter)
#### Post date: [September 18, 2020, 3:06pm UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/13 "2020-09-18T15:06:24Z")

</div>

The one thing that’s been very painful for us here at the Mayo Clinic is the difficulty with getting answers to many issues. But, I’ll just blame my incompetence until proven otherwise. 🙂

Thanks for letting me vent 🤙🏻

Anyway, Is there a definite direct simple answer to how to generate version 9 vtk.jar that can be officially documented and will work for most? I have never heard of Ninja. How exactly do you use it?

Thanks so much! ✌🏻

---

<div class="post-metadata">

### Author: ![dporter](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dporter](https://discourse.vtk.org/u/dporter)
#### Post date: [September 18, 2020, 3:12pm UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/14 "2020-09-18T15:12:13Z")

</div>

Bottom line, does an answer exist? If so, could someone be nice enough to take some time to help us? That would be so appreciated and I will nominate you for a Nobel Peace Prize or something. Thanks!

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [September 18, 2020, 3:57pm UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/15 "2020-09-18T15:57:14Z")

</div>

Ninja is a build tool (like `make`), but without a lot of the Unix assumptions around it.

On Windows, the general steps to build VTK with it are:

- open a developer prompt for the VS toolchain you want to use (should be in the Start Menu and should mention `x64 Host` in some form)
- in the prompt, configure VTK using `cmake -GNinja /path/to/vtk/source`
- you can use `cmake-gui` to edit options as you need (run it from the command prompt so that it keeps the Visual Studio information available)
- still in the prompt, run `cmake --build .` which should make the `.jar` file with the DLLs near it

---

<div class="post-metadata">

### Author: ![eclrgp](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/e/e9a140/32.png) [@eclrgp](https://discourse.vtk.org/u/eclrgp)
#### Post date: [September 19, 2020, 9:26am UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/16 "2020-09-19T09:26:15Z")

</div>

As Daniel has said the official advice is to use ninja.

However if you do not want to install an extra piece of software it is very easy to complete the build process for the java wrappers if you use Visual Studio.

I assume you have configured cmake to include the java  
wrappers  
The VS cmake does not know how to build java files so the last  
stage of building vtk.jar file has to be done manually since vtk  
9.0.0  
At a command prompt and assuming the source has been  
unpacked to \vtk-9.0.1

cd \vtk-9.0.1\Wrapping\Java  
dir /s/B \*.java \>javafiles  
javac -d /vtk-9.0.1/java @javafiles  
cd \vtk-9.0.1\java  
jar --create -f …/bin/vtk.jar vtk/.class

The java wrapper dlls are stored separately from the other vtk dlls  
There are in

\VTK-9.0.1\lib\java\vtk-Windows-AMD64\Release  
or  
\VTK-9.0.1\lib\java\vtk-Windows-AMD64\Debug

Both sets of dlls need to be in the path

Ray

Date sent: Wed, 22 Jul 2020 10:59:22 +0000  
Send reply to: VTK [vtk+8b1cafcba92a11d2732025d7b1b9d26d@discourse.vtk.org](mailto:vtk+8b1cafcba92a11d2732025d7b1b9d26d@discourse.vtk.org)  
Also location of wrapper dlls  
Date sent: Fri, 18 Sep 2020 15:12:14 +0000  
Send reply to: VTK [vtk+fea01a644757d8856e7a68dc492597c0@discourse.vtk.org](mailto:vtk+fea01a644757d8856e7a68dc492597c0@discourse.vtk.org)  
location of wrapper dlls

> Bottom line, does an answer exist? If so, could someone be nice enough to take some time to  
> help us? That would be so appreciated and I will nominate you for a Nobel Peace Prize or  
> something. Thanks!
> 
> Visit Topic or reply to this email to respond.  
> To unsubscribe from these emails, click here.

Ray and Pamela Powell  
Phone: 0113 2550286

---

<div class="post-metadata">

### Author: ![dporter](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dporter](https://discourse.vtk.org/u/dporter)
#### Post date: [November 16, 2020, 6:41pm UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/17 "2020-11-16T18:41:39Z")

</div>

Thanks Ray! I appreciate this. We will try this.

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [May 2, 2021, 5:46am UTC](https://discourse.vtk.org/t/vtk-9-and-java-vtk-jar-not-automatically-generated-also-location-of-wrapper-dlls/3354/19 "2021-05-02T05:46:41Z")

</div>

> [@eclrgp](#):
>
> cd \vtk-9.0.1\Wrapping\Java  
> dir /s/B \*.java \>javafiles  
> javac -d /vtk-9.0.1/java @javafiles  
> cd \vtk-9.0.1\java  
> jar --create -f …/bin/vtk.jar vtk/.class

That should be

```auto
cd $vtk_build_dir\Wrapping\Java
dir /s/B *.java >javafiles
javac -d ..\..\java @javafiles
cd ..\..\java
jar --create -f ..\lib\java\vtk.jar vtk\*.class

```

then run

```auto
cd $vtk_build_dir\Wrapping\Java\vtk\sample
java -cp $vtk_build_dir\lib\java\vtk.jar Demo.java

```
