<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 6.00.2800.1141" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=291590714-06062003><FONT face=Arial color=#0000ff 
size=2>Greg,</FONT></SPAN></DIV>
<DIV><SPAN class=291590714-06062003><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=291590714-06062003><FONT face=Arial color=#0000ff size=2>From 
the Sun book on JNI by Sheng Liang, here is a rough outline of the 
process:</FONT></SPAN></DIV>
<DIV><SPAN class=291590714-06062003><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=291590714-06062003><FONT face=Arial color=#0000ff size=2>1. 
Create a Java class that declares the native method. (e.g. 
myClass.java)</FONT></SPAN></DIV>
<DIV><SPAN class=291590714-06062003><FONT face=Arial color=#0000ff size=2>2. Use 
the Java compiler, javac, to compile the Java class, resulting in the file 
myClass.class</FONT></SPAN></DIV>
<DIV><SPAN class=291590714-06062003><FONT face=Arial color=#0000ff size=2>3. Use 
the javah -jni utility to create a C header file myClass.h</FONT></SPAN></DIV>
<DIV><SPAN class=291590714-06062003><FONT face=Arial color=#0000ff size=2>4. 
Write the C implementation of the native method, e.g. 
myJNI.c</FONT></SPAN></DIV>
<DIV><SPAN class=291590714-06062003><FONT face=Arial color=#0000ff size=2>5. 
Compile the C implementation into a native dynamic library, e.g., myJNI.dll or 
myJNI.so</FONT></SPAN></DIV>
<DIV><SPAN class=291590714-06062003><FONT face=Arial color=#0000ff size=2>6. Run 
the myClass Java program using&nbsp;'java myClass.class'. The Java class loader 
will dynamically load your Java class and the native method 
library.</FONT></SPAN></DIV>
<DIV><SPAN class=291590714-06062003><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=291590714-06062003><FONT face=Arial color=#0000ff size=2>If you 
are using, say, MS Visual C++, you can use the new project wizard to tell it you 
are building a DLL instead of an application. It will put all the appropriate 
linker flags in for you to build a dll.</FONT></SPAN></DIV>
<DIV><SPAN class=291590714-06062003><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=291590714-06062003><FONT face=Arial color=#0000ff 
size=2>Starting with a 'hello world' program that does not try to pass any data 
between the C and Java worlds is a good first step.</FONT></SPAN></DIV>
<DIV><SPAN class=291590714-06062003><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=291590714-06062003><FONT face=Arial color=#0000ff size=2>-Bill 
Leue</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> Greg Scott 
  [mailto:g.scott@oneteldsl.net]<BR><B>Sent:</B> Friday, June 06, 2003 10:03 
  AM<BR><B>To:</B> vtkusers@public.kitware.com<BR><B>Subject:</B> [vtkusers] 
  Help with linking C++ native code for Java JNI<BR><BR></FONT></DIV>
  <DIV><FONT face=Arial size=2>Hello everyone,</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>Following a recent post, I thought I would try 
  writing some C++ code which will had back an array to Java. Whilst I can get 
  basic "Hello World" type JNI programs to work, I've having difficulty in doing 
  anything that uses vtk-based methods for Java. On linking a program which uses 
  vtkJavaUtils.h, e.g. to invoke the vtkJavaGetPointerFromObject() method, I get 
  the following error:</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>error LNK2001: unresolved external symbol "void * 
  __cdecl vtkJavaGetPointerFromObject(struct JNIEnv_ *,class jobject *,char *)" 
  (?vtkJavaGetPoi<A 
  href="mailto:?vtkJavaGetPointerFromObject@@YAPAXPAUJNIEnv_@@PAV_jobject@@PAD@Z">nterFromObject@@YAPAXPAUJNIEnv_@@PAV_jobject@@PAD@Z</A>)<BR></FONT></DIV>
  <DIV><FONT face=Arial size=2>Does anyone know which .lib file the vtkJavaUtil 
  code have been incorporated in? I thought I was including all of those 
  required. I get the same error through Visual C++ IDE and from the 'cl' 
  command-line approach.</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>Any advice much appreciated,</FONT></DIV>
  <DIV><FONT face=Arial size=2>Greg</FONT></DIV>
  <DIV><FONT face=Arial size=2>&nbsp;</DIV></FONT>
  <DIV><FONT face=Arial size=2>&nbsp;</DIV></FONT>
  <DIV><FONT face=Arial size=2>&nbsp;</DIV></BLOCKQUOTE></FONT></BODY></HTML>