tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leon Palermo" <>
Subject Re: IIS, tomcat and java ...
Date Wed, 01 Nov 2000 12:18:05 GMT

You need to use JNI to access the methods in the .dll.  If you have already
done that from an application, create a jsp or servlet that uses the class
and call the appropriate methods.

Here is a quick example of a Java class that calls native .dll:

public class DllTest{
    //Two native method from the 'mydll.dll'
    public native String[] returnTestArray();
    public native String getTestString();


    //Test the native methods and print results to ServletOutputStream
    public static void test(ServletOutputStream out) {
        DllTest newDll = new DllTest();
        String[] ar = newDll.returnTestArray();
        for (int i=0; i<5; i++) {
           out.println("array element"+i+ "=" + ar[i]);

Here are the methods in C++ using JNI:

#include "stdafx.h"
//JNI header
#include "jni.h"
//Notice I create a header file to use from my preious
//Java class using 'javah' utility
#include "DllTest.h"

JNIEXPORT jobjectArray JNICALL Java_ArrayHandler_returnArray
  (JNIEnv *env, jobject jobj){

    jobjectArray ret;
    int i;

    char *message[5]= {"first",

    ret= (jobjectArray)env->NewObjectArray(5,

    for(i=0;i<5;i++) {

JNIEXPORT jstring JNICALL Java_ArrayHandler_lastFile
(JNIEnv *env, jobject){
    return  env->NewStringUTF("Test String");

Here is a .jsp file that calls the class which calls the .dll:

<%@ page session="false"%>


The results should be:
Test String
array element0=first
array element1=second

I hope all of this helps.  And don't worry about the English; I am sure I
don't speak your language well either.

Leon Palermo
Zedak Corporation
Valhalla, NY

> hi all :
> This is the first time i write (and i don speak a good english, sorry
all )
> I have a .dll and i need know how acces at methods of this dll with java
> My first step is with a java aplication (simple), create a instnace of the
.dll, but i don know how
> i do ...
> do you undertendme ??
> Thanks ...
> Sorry for my bad english i need pratice ... =-(

View raw message