[vtkusers] vtkPanel and JAVA 1.4

JL jclopez+vtk at andrew.cmu.edu
Tue Apr 16 15:08:30 EDT 2002


Hi Jason,

I am enclosing a modified version of vtkPanel (and the
corresponding) native routines.  These two files are
taken from VTK 4.0.  I made some minor modifications,
which include making vtkPanel part of the vtk package.

Although, I compiled with JDK 1.3., it should work with
JDK 1.4 if the only requirements are the ones you
mentioned in your previous mail.

I ran a small test program against vtk3.2 on windows and
it works.  However, I'm not sure whether it would work
on other platforms.  I haven't played with VTK 4.0,
mainly 'cause I haven't taken the time to see how CMake
works.  That said, it means I have not built this version
of vtkPanel against VTK 4.0.  It was confusing why
vtkJavaAwt was a header file (.h) and not a C++ file
(.cxx) and where it was included from, etc.

I think changes are required in the configuration in
order to build this version of vtkPanel with vtk 4.0.
Anyway, I build a separate vtkPanel library that
contains only the native methods for vtkPanel.

You are welcome to try it and maybe someone might
volunteer to test the changes on different platforms
and integrate them in the main source tree.

So, here's how I go around building the support for
vtkPanel.  Essentially, I build it separately from vtk.

I build a separate shared library for vtkPanel
(i.e. vtkPanel.dll or libvtkPanel.so) from vtkJavaAwt.cxx.
I've included a pseudo-makefile, that probably won't work
if used directly, but illustrates what it is required to
build the vktPanel library.

vtkPanel.dll is linked against:
 - vtkJava.lib
 - vtkCommon.lib
 - vtkGraphics0.lib
 - $(JDKDIR)/lib/jawt.lib where JDKDIR is the topmost
   directory of the JDK installation.

And vtkPanel is compiled as usual, "linking" against vtk.jar.

javac -classpath directory_where_your_vtk_jar_is/vtk.jar:. \
	vtk/vtkPanel.java

And to execute, make sure that the appropriate CLASSPATH is set
and that the libraries can be found by the dynamic loader, that
is the path to the directory where your libraries are is in the
PATH variable for Windows or in LD_LIBRARY_PATH for Unix.

By now, I have confused everyone.  I apologize I cannot make
things easier/clearer, but I'm sure there are many people out
there that can do a better job making the build process easier
and integrating the changes into VTK.

I hope this helps,

-- Julio

------------ pseudo-makefile begin ------------

ALL : vtkPanel.dll

JDKDIR    = your_jdk_dir_here
VTKSRCDIR = your_vtk_dir_here
VTKBINDIR = your_vtk_build_dir_here
PLATFORM  = win32

INCLUDES  = -I "$(VTKSRCDIR)/common" -I "$(VTKSRCDIR)/graphics" \
	    -I "$(JDKDIR)/include" -I "$(JDKDIR)/include/$(PLATFORM)" \
	    -I "$(VTKBINDIR)"

CXX_FLAGS = -nologo -G6 -MT -W3 -GX- -Od -DWIN32 -DDEBUG -D_WINDOWS -D_MBCS
\
	    -D_USRDLL -FD -c

LINK32	     = link.exe
LIBS 	     = vtkJava.lib vtkCommon.lib vtkGraphics0.lib
$(JDKDIR)/lib/jawt.lib
LINK32_FLAGS = -nologo -dll -incremental:no -machine:I386 -out:vtkPanel.dll
\
	     = -implib:vtkPanel.lib -libpath:$(VTKBINDIR)/lib

vtkPanel.dll: $(LIBS) vtkJavaAwt.obj
	$(LINK32) @<<
  $(LINK32_FLAGS) $(LIBS) vtkJavaAwt.obj
<<

vtkJavaAwt.obj: vtkJavaAwt.cxx # And other dependencies
	$(CPP) $(CPP_PROJ) $(SOURCE)

------------ pseudo-makefile end ------------




> -----Original Message-----
> From: vtkusers-admin at public.kitware.com
> [mailto:vtkusers-admin at public.kitware.com]On Behalf Of
> jason_donmoyer at chiinc.com
> Sent: Tuesday, April 16, 2002 9:46 AM
> To: vtkusers at public.kitware.com
> Subject: [vtkusers] vtkPanel and JAVA 1.4
>
>
> The class vtkPanel distributed with the vtk examples will not
> compile using
> J2SDK 1.4.  The following excerpt from the release notes explains why:
>
> ------
>
> The compiler now rejects import statements that import a type from the
> unnamed namespace. Previous versions of the compiler would accept such
> import declarations, even though they were arguably not allowed by the
> language (because the type name appearing in the import clause is not in
> scope). The specification is being clarified to state clearly that you
> cannot have a simple name in an import statement, nor can you import from
> the unnamed namespace.
> To summarize, the syntax
>
> import SimpleName;
>
> is no longer legal. Nor is the syntax
> import ClassInUnnamedNamespace.Nested;
>
> which would import a nested class from the unnamed namespace. To fix such
> problems in your code, move all of the classes from the unnamed namespace
> into a named namespace.
>
> -----------
>
>
> You can temporarily get around this problem by compiling vtkPanel with an
> older version of the JDK while continuing to use J2SDK 1.4 for the rest of
> your classes.  Steps should be taken to fix this problem so that
> it complies
> with the latest version of the JDK.  This is important so that
> users of vtk
> can take advantage of the performance benefits of 1.4 without resorting to
> recreating the JNI calls.
>
> Thank you,
>
> Jason Donmoyer
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkJavaAwt.cxx
Type: application/octet-stream
Size: 6172 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20020416/9e21d4d4/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkPanel.java
Type: text/java-source
Size: 8737 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20020416/9e21d4d4/attachment.bin>


More information about the vtkusers mailing list