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?
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.
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.
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.
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
You need to use the developer prompt to get the MSVC environment loaded.
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
Also location of wrapper dlls
Thank you very much, this looks very promising.
I’ll try it out later and I’ll be in touch.
Daniel
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?
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
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$ (1.95 KB)
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 .
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
Also location of wrapper dlls
Daniel
July 24Thank 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 24Hello 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
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
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!
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!
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
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
Also location of wrapper dlls
Date sent: Fri, 18 Sep 2020 15:12:14 +0000
Send reply to: VTK 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
Thanks Ray! I appreciate this. We will try this.
That should be
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
cd $vtk_build_dir\Wrapping\Java\vtk\sample
java -cp $vtk_build_dir\lib\java\vtk.jar Demo.java