Invoking Native Dll in Java

Hi,
We have tried to invoke a native dll method using JNI in java.
While invoking the dll method(below native code dll) we face the "Access violation error".
But the very same native implementation code is working successfully when invoked from VC++ Exe application.
We have given the Java class file, header file, CPP implementation of the method and the error report below.
Can anybody let us know if there is some fault in the way code we have coded?
*{color:#0000ff}Source Code:{color}
{color:#0000ff}---------------------{color}
_______________________________________WsqLib.java____________________________________________________________________
class WsqLib
private native int BitmapToWSQ();
private native int WsqToBitmap();
public static void main(String[] args)
WsqLib wsqlib=new WsqLib();
System.out.println("wsqlib.BitmapToWSQ() ==> "+wsqlib.BitmapToWSQ());
static
System.loadLibrary("WsqLib");
# Create a class (WsqLib.java) that declares the native method.
# We use javac to compile the WsqLib source file, resulting in the class file WsqLib.class.
# We use javah to generate a C header file (WsqLib.h) containing the function prototype for the native method implementation.*
_______________________________________WsqLib.h*_______________________________________________________________________
/* DO NOT EDIT THIS FILE - it is machine generated */
#include "jni.h"
/* Header for class WsqLib */
#ifndef IncludedWsqLib
#define IncludedWsqLib
#ifdef __cplusplus
extern "C" {
#endif
* Class: WsqLib
* Method: BitmapToWSQ
* Signature: ()I
JNIEXPORT jint JNICALL Java_WsqLib_BitmapToWSQ
(JNIEnv *, jobject);
* Class: WsqLib
* Method: WsqToBitmap
* Signature: ()I
JNIEXPORT jint JNICALL Java_WsqLib_WsqToBitmap
(JNIEnv *, jobject);
#ifdef __cplusplus
#endif
#endif
# CPP implementation (WsqLib.cpp) of the native method is as below.
# We compiled the cpp implementation into a native library, creating WsqLib.dll.
# We use the WsqLib.dll in WsqLib.java.
_______________________________________WsqLib.cpp______________________________________________________________________
#include "stdafx.h"
#include "WsqLib.h"
#include "_vcclrit.h"
#include "gdiplus.h"
#include <afxstr.h>
#include <atlimage.h>
#include "WsqLib1.h"
static const GUID guidBmp =
{ 0x557cf400, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e } };
extern "C"
int debug = 0;
JNIEXPORT jint JNICALL Java_WsqLib_BitmapToWSQ(JNIEnv *, jobject)
Gdiplus::Bitmap *pBitmap = Gdiplus::Bitmap::FromFile(L"temp.bmp", TRUE);
Gdiplus::BitmapData lockedBitmapData;
Gdiplus::Rect rect(0, 0,pBitmap->GetWidth(),pBitmap->GetHeight());
//Error occured in this Line.
pBitmap->LockBits( &rect, Gdiplus::ImageLockModeRead, PixelFormat8bppIndexed, &lockedBitmapData );
int byteCount = pBitmap->GetWidth() * pBitmap->GetHeight() * (int)(8 / 8);
unsigned char *pPixelData2 = new unsigned char[byteCount];
memset(pPixelData2, 0, (size_t)byteCount);
unsigned char pBytes = (unsigned char) lockedBitmapData.Scan0;
for (int index = 0; index < byteCount; index++)
pPixelData2[index] = pBytes[index];
pBitmap->UnlockBits(&lockedBitmapData);
unsigned char *pPixelData = pPixelData2;
int pixelsPerInch = (int)pBitmap->GetHorizontalResolution();
float compressionFactor = (float)( (float)((int)75) / 100.0);
unsigned char *pWsqBytes = NULL;
int wsqBytesCount = 0;
int result = 0;
result = wsq_encode_mem(
&pWsqBytes, // Output data buffer
&wsqBytesCount, // Length of output data buffer
compressionFactor, // Determines the amount of lossy compression.
pPixelData, // Input pixel data
pBitmap->GetWidth(), // Pixel width of the pixmap
pBitmap->GetHeight(), // Pixel height of the pixmap
8, // Depth (bits) of the pixmap
pixelsPerInch, // Scan resolution of the image in integer units of pixels per inch
(char *)NULL // Optional (we do not want to use this - we may even want to remove the implementation)
if (result == 0)
FILE *fptr1;
fptr1=fopen("C:\\saran2.wsq_1.0","wb");
fwrite(pWsqBytes,wsqBytesCount,1,fptr1);
fclose(fptr1);
return 10;
JNIEXPORT jint JNICALL Java_WsqLib_WsqToBitmap(JNIEnv *, jobject)
BYTE gData[242998];
Gdiplus::Bitmap* image;
CFile file;
file.Open("temp.wsq_1.0",CFile::modeRead,NULL);
file.Read(gData,242998);
unsigned char pByteArray =(unsigned char)gData;
unsigned char *pPixelData = NULL;
int bitmapWidth = 0;
int bitmapHeight = 0;
int pixelDepth = 0;
int pixelsPerInch = 0;
int lossyFlag = 1;
int byteArrayLength = 242998;
int result = 0;
result = wsq_decode_mem(
&pPixelData, // Output image buffer
&bitmapWidth, // Pixel width of the pixmap
&bitmapHeight, // Pixel height of the pixmap
&pixelDepth, // Depth (bits) of the pixmap
&pixelsPerInch, // Scan resolution of the image in integer units of pixels per inch
&lossyFlag, // Is the image lossy? F.I.I.K.
pByteArray, // Input data buffer
byteArrayLength // Input data buffer length
if (result == 0 && pixelDepth == 8)
image = new Gdiplus::Bitmap(bitmapWidth, bitmapHeight);
Gdiplus::Rect bound( 0, 0,bitmapWidth,bitmapHeight);
Gdiplus::BitmapData lockedBitmapData;
image->LockBits( &bound, Gdiplus::ImageLockModeWrite, PixelFormat8bppIndexed, &lockedBitmapData );
int imageRowSize = bitmapWidth * (8/8);
unsigned char pBitmapPixelData = (unsigned char )lockedBitmapData.Scan0;
int byteCount = bitmapWidth * bitmapHeight;
for (int index = 0; index < byteCount; index++)
pBitmapPixelData[index] = pPixelData[index];
image->UnlockBits( &lockedBitmapData );
else
return result;
image->Save(L"C:\\temp.bmp", &guidBmp);
return 0;
{color:#0000ff}Error report:{color}
{color:#0000ff}-------------------{color}
# An unexpected error has been detected by HotSpot Virtual Machine:
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x03920780, pid=380, tid=3572
# Java VM: Java HotSpot(TM) Client VM (1.5.0_12-b04 mixed mode, sharing)
# Problematic frame:
# C 0x03920780
--------------- T H R E A D ---------------
Current thread (0x00036d88): JavaThread "main" [_thread_in_native, id=3572]
siginfo: ExceptionCode=0xc0000005, reading address 0x00000004
Registers:
EAX=0x00000000, EBX=0x00000000, ECX=0x00000000, EDX=0x00000000
ESP=0x0007f9a8, EBP=0x0007fa70, ESI=0x00000000, EDI=0x00000000
EIP=0x03920780, EFLAGS=0x00010246
Top of Stack: (sp=0x0007f9a8)
0x0007f9a8: 00000000 00000000 00000000 00000000
0x0007f9b8: 039204ba 00000001 00000000 000be780
0x0007f9c8: 03726248 0007fa10 00000000 00000000
0x0007f9d8: 03920430 0007fa2c 7a32b4fa ffffffff
0x0007f9e8: 0007fa38 79e7bba9 79e7bbb1 cce41966
0x0007f9f8: ffffffff 0007fa68 000a4b30 00000000
0x0007fa08: 00000000 00000000 00000000 00000000
0x0007fa18: 00000000 00000000 00000000 00000000
Instructions: (pc=0x03920780)
0x03920770: 03 00 74 05 e8 85 1b 77 76 33 d2 89 14 24 8b fe
0x03920780: 8b 4e 04 8d 14 24 e8 05 65 e0 ff 8b d8 8b d3 8b
Stack: [0x00040000,0x00080000), sp=0x0007f9a8, free space=254k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C 0x03920780
C 0x031e3171
j WsqLib.BitmapToWSQ()I+0
j WsqLib.main([Ljava/lang/String;)V+24
v ~StubRoutines::call_stub
V [jvm.dll+0x87599]
V [jvm.dll+0xdfbb2]
V [jvm.dll+0x8746a]
V [jvm.dll+0x8e6ac]
C [java.exe+0x14c5]
C [java.exe+0x69cd]
C [kernel32.dll+0x16d4f]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j WsqLib.BitmapToWSQ()I+0
j WsqLib.main([Ljava/lang/String;)V+24
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x009f2b28 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=3996]
0x009f1820 JavaThread "CompilerThread0" daemon [_thread_blocked, id=2832]
0x009f0a68 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=404]
0x009eb330 JavaThread "Finalizer" daemon [_thread_blocked, id=3304]
0x009e9eb0 JavaThread "Reference Handler" daemon [_thread_blocked, id=1648]
=>0x00036d88 JavaThread "main" [_thread_in_native, id=3572]
Other Threads:
0x009c8508 VMThread [id=492]
0x009f0528 WatcherThread [id=2924]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 576K, used 497K [0x22a50000, 0x22af0000, 0x22f30000)
eden space 512K, 84% used [0x22a50000, 0x22abc5b8, 0x22ad0000)
from space 64K, 99% used [0x22ae0000, 0x22aefff8, 0x22af0000)
to space 64K, 0% used [0x22ad0000, 0x22ad0000, 0x22ae0000)
tenured generation total 1408K, used 115K [0x22f30000, 0x23090000, 0x26a50000)
the space 1408K, 8% used [0x22f30000, 0x22f4cc28, 0x22f4ce00, 0x23090000)
compacting perm gen total 8192K, used 20K [0x26a50000, 0x27250000, 0x2aa50000)
the space 8192K, 0% used [0x26a50000, 0x26a553b8, 0x26a55400, 0x27250000)
ro space 8192K, 63% used [0x2aa50000, 0x2af60590, 0x2af60600, 0x2b250000)
rw space 12288K, 46% used [0x2b250000, 0x2b7f21b0, 0x2b7f2200, 0x2be50000)
Dynamic libraries:
0x00400000 - 0x0040d000 C:\WINDOWS\system32\java.exe
0x7c900000 - 0x7c9b0000 C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c8f4000 C:\WINDOWS\system32\kernel32.dll
0x77dd0000 - 0x77e6b000 C:\WINDOWS\system32\ADVAPI32.dll
0x77e70000 - 0x77f01000 C:\WINDOWS\system32\RPCRT4.dll
0x77c10000 - 0x77c68000 C:\WINDOWS\system32\MSVCRT.dll
0x6d640000 - 0x6d7dd000 C:\Program Files\Java\jre1.5.0_12\bin\client\jvm.dll
0x77d40000 - 0x77dd0000 C:\WINDOWS\system32\USER32.dll
0x77f10000 - 0x77f56000 C:\WINDOWS\system32\GDI32.dll
0x76b40000 - 0x76b6d000 C:\WINDOWS\system32\WINMM.dll
0x6d290000 - 0x6d298000 C:\Program Files\Java\jre1.5.0_12\bin\hpi.dll
0x76bf0000 - 0x76bfb000 C:\WINDOWS\system32\PSAPI.DLL
0x6d610000 - 0x6d61c000 C:\Program Files\Java\jre1.5.0_12\bin\verify.dll
0x6d310000 - 0x6d32d000 C:\Program Files\Java\jre1.5.0_12\bin\java.dll
0x6d630000 - 0x6d63f000 C:\Program Files\Java\jre1.5.0_12\bin\zip.dll
0x10000000 - 0x10075000 D:\Jagadeesan\JNI_NEW\WSQ\WsqLib.dll
0x79000000 - 0x79045000 C:\WINDOWS\system32\mscoree.dll
0x7c140000 - 0x7c357000 C:\WINDOWS\system32\MFC71D.DLL
0x10200000 - 0x10287000 C:\WINDOWS\system32\MSVCR71D.dll
0x77f60000 - 0x77fd6000 C:\WINDOWS\system32\SHLWAPI.dll
0x77120000 - 0x771ac000 C:\WINDOWS\system32\OLEAUT32.dll
0x774e0000 - 0x7761c000 C:\WINDOWS\system32\ole32.dll
0x4ec50000 - 0x4edf3000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.GdiPlus_6595b64144ccf1df_1.0.2600.2180_x-ww_522f9f82\gdiplus.dll
0x5d360000 - 0x5d36e000 C:\WINDOWS\system32\MFC71ENU.DLL
0x79e70000 - 0x7a3d1000 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
0x78130000 - 0x781cb000 C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd\MSVCR80.dll
0x7c9c0000 - 0x7d1d4000 C:\WINDOWS\system32\shell32.dll
0x773d0000 - 0x774d2000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll
0x5d090000 - 0x5d127000 C:\WINDOWS\system32\comctl32.dll
0x790c0000 - 0x79ba6000 C:\WINDOWS\assembly\NativeImages_v2.0.50727_32\mscorlib\bf3b003e3ac7e449bdf8fc9375318452\mscorlib.ni.dll
0x79060000 - 0x790b3000 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorjit.dll
0x5e380000 - 0x5e409000 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\diasymreader.dll
VM Arguments:
java_command: WsqLib
Launcher Type: SUN_STANDARD
Environment Variables:
JAVA_HOME=C:\Program Files\Java\jdk1.5.0_12;
CLASSPATH=C:\Program Files\Apache Software Foundation\Tomcat 5.5\shared\lib\*.jar;C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\axis\WEB-INF\classes\org\apache\axis\transport\http\*.classs;D:\JONAS_4_6_6\lib\ext\axis.jar;C:\Sun\jwsdp-1.6\jaxp\lib\endorsed\sax.jar;C:\tomcat50-jwsdp\jaxp\lib\endorsed\sax.jar;C:\Files\Java\jdk1.5.0_01\jre\lib;C:\Program Files\Java\jdk1.5.0_12\jre\lib\ext;
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;D:\Jagadeesan Backup\DotNet\DynamicLibrary\MathFuncsDll\Debug;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies;C:\Sun\jwsdp-1.6\jaxrpc\bin;C:\Sun\jwsdp-1.6\jaxp\lib;C:\Sun\jwsdp-1.6\jaxp\lib\endorsed;C:\Program Files\Java\jdk1.5.0_12\bin;C:\Sun\jwsdp-1.6\jwsdp-shared\bin;C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Sun\jwsdp-1.6\jaxrpc\bin;C:\Sun\jwsdp-1.6\jaxp\lib;C:\Sun\jwsdp-1.6\jaxp\lib\endorsed;C:\Program Files\Java\jdk1.5.0_12\bin;
USERNAME=Administrator
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 15 Model 1 Stepping 2, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows XP Build 2600 Service Pack 2
CPU:total 1 (cores per cpu 1, threads per core 1) family 15 model 1 stepping 2, cmov, cx8, fxsr, mmx, sse, sse2
Memory: 4k page, physical 259888k(81380k free), swap 636388k(342588k free)
vm_info: Java HotSpot(TM) Client VM (1.5.0_12-b04) for windows-x86, built on May 2 2007 02:07:59 by "java_re" with MS VC++ 6.0

Is there any other reason for this error?There is one and only one reason for the error code 0xc0000005 - there is a pointer (C/C++) pointing somewhere it shouldn't.
The above C code working fine while invoking in VC++ Exe application,
But the error occured only while invoking in java using JNI.Which suggests only that sometimes that it works. It doesn't mean that it always works.
There are a number of places in the C/C++ code where it could fail and none of them are being checked.

Similar Messages

  • How can applet invoke native dll?

    Is it possible for an applet invoke native source?

    All in all it's not an especially practical idea.For Applets, I agree.
    However if you were to use JavaWebStart/JNLP, support for JNI shared objects is built into the protocol. You would still have to sign the application though.

  • How to invoke my dll in java?

    hi:
    I use Jawin Type Browser generate two java files(DES_in_VBA.java,_DES_in_VBA.java),but I do not know how to use this two java files,beacuse this is my first to use Jawin. Can you tell me Where the two files should to be place,and how to use it good.I had read Jawin's docs,but can not understand it for my poor english.
    Thank you for your help again!!!
    I want use 'FuncPtr' to invoke it,but there can not found the match Invok_* file's.I do not know how to pass my function's paramters!
    There are two function's in my ".dll" file:
    Public Sub DES_Encode(ByRef sCode() As Byte, ByVal sKey As String, ByRef bReturn() As Byte)
    Public Sub DES_Decode(ByRef sCode() As Byte, ByVal sKey As String, ByRef bReturn() As Byte)
    Can you tell me how to invoke the two functions in java,and can you give me a example about how to invoke the two functions?
    Thank you for your help

    http://java.sun.com/docs/books/tutorial/native1.1/index.html

  • Calling DLLs or Java from Business Objects

    Post Author: nmarks
    CA Forum: Other
    I'm a newbie so please go easy!
    Is it possible to invoke a DLL or Java bean when opening a Business Objects query or report?
    I've just started working for a very large insurance company in the UK.
    Each month the company produces reports for the Directors, for the Auditors and Industry Regulators.
    Most of the results that go into the reports are produced using an extremely expensive application called Prophet. It dumps out files with data in.
    Ideally the company would like to upload the results from Prophet into Business Objects and have nice numbers show on a report the directors can understand.
    The problem is that lots of fiddly adjustment calculations have to be done to the data coming from Prophet before it can be shown on the BO report.
    I have proposed that the adjustment calculations are done using a VB DLL which will be called automatically by Business Objects  when the user wants to see the report. Can this be done?
    Can Business Objects call a DLL?
    Your help is very much appreciated.
    Regards,
    Nick.

    Post Author: thangvq
    CA Forum: Other
    Hello,
    I think it can. At least I have done it with a DLL is compiled by Delphi. You may read the CR Developer's Help for more info. If you have installed the Developer Edition, its location is something like this: C:\Program Files\Business Objects\Crystal Reports 11\Developer Files\Help\En
    Thang

  • How to deploy the native dll with the applet package by Sun Java Plugin

    I have an applet which use some native methods. I have written code for the native dll, but I don't know how to deploy the DLL with the applet jar file for Sun Java Plugin. What parameter do i should pass to System.loadLibrary()? I think the solution should don't care which browser used by the end client. How to do it? How to deal with the applet security problem?
    Thank for any comment!

    I have a similar problem.
    Trying to use the javax.comm package requires that the user have the win32com.dll located on their machine.
    I have solved the problem by using a signed applet that allows me to write the dll to the clients machine and then run the code but ideally I would like to run the code without writing the dll to the users machine...i.e. I want to load the dll directly through the applet in the same way the class files are loaded forthe applet are loaded without copying them to the clients machine. After trying everything I have come to the conclusion that it is NOT possible. The calls loadLibrary and load both require that the dll reside on the clients machine. If anyone has had a different experience please rebut this.
    Rob

  • Cannot get bitmap from native DLL from multi threaded Java app.

    I have a native DLL that gives me a HBITMAP (Windows handle to bitmap). I have made a JNI wrapper for this that gives me a BufferedImage back. The native code simple gets the actual bitmap for the handle, converts the RGB byte triplets to RGB ints, puts this in a jintArray and creates a BufferedImage.
    This all works fine within a single Java thread. If I do this multi threaded (thread 1 calls the native function and several seconds later, thread 2 calls the native function) I keep getting the last image of the first thread. Can enyone help me out?
    I know that this is probably a question for MSDN but I just know that they will tell me its a JNI question.
    The native code:
    JNIEXPORT jobject JNICALL Java_somenamespace_getPicture
    (JNIEnv *env, jclass cl, jstring serialNumber)
    jobject jImage;
    jclass jImageClass;
    jmethodID jMethod;
    jfieldID jField;
    jintArray rgbArray;
    char *str;
    char *charArray;
    int *intArray;
    int w, h, index, type;
    HBITMAP hbmp;
    BITMAP bmp;
    str = (char*)((*env)->GetStringUTFChars(env, serialNumber, NULL));
    // Gets the HBITMAP handle from the native DLL. The first argument is to select the device, based on serial number.
    getPicture(str, &hbmp);
    (*env)->ReleaseStringUTFChars(env, serialNumber, str);
    // Get the BITMAP for the HBITMAP
    GetObject(hbmp, sizeof(BITMAP), &bmp);
    // Create my BufferedImage
    jImageClass = (*env)->FindClass(env, "java/awt/image/BufferedImage");
    jMethod = (*env)->GetMethodID(env, jImageClass, "<init>", "(III)V");
    jField = (*env)->GetStaticFieldID(env, jImageClass, "TYPE_INT_RGB", "I");
    type = (*env)->GetStaticIntField(env, jImageClass, jField);
    jImage = (*env)->NewObject(env, jImageClass, jMethod, bmp.bmWidth, bmp.bmHeight, type);
    // Get the RGB byte triplets of the BITMAP
    charArray = (char *)malloc(sizeof(char) * bmp.bmHeight * bmp.bmWidth * 3);
    GetBitmapBits(hbmp, sizeof(char) * bmp.bmHeight * bmp.bmWidth * 3, charArray);
    // Allocate space to store the RGB ints and convert the RGB byte triplets to RGB ints
    intArray = (int *)malloc(sizeof(int) * bmp.bmHeight * bmp.bmWidth);
    index = 0;
    for (h = 0; h < bmp.bmHeight; ++h)
    for (w = 0; w < bmp.bmWidth; ++w)
    int b = *(charArray + index * 3) & 0xFF;
    int g = *(charArray + index * 3 + 1) & 0xFF;
    int r = *(charArray + index * 3 + 2) & 0xFF;
    *(intArray + index) = 0xFF000000 | (r << 16) | (g << 8) | b;
    ++index;
    // Create a jintArray for the C RGB ints
    rgbArray = (*env)->NewIntArray(env, bmp.bmHeight * bmp.bmWidth);
    (*env)->SetIntArrayRegion(env, rgbArray, 0, bmp.bmHeight * bmp.bmWidth, (jint*)intArray);
    // Use BufferedImage.setRGB() to fill the image
    jMethod = (*env)->GetMethodID(env, jImageClass, "setRGB", "(IIII[III)V");
    (*env)->CallVoidMethod(env, jImage, jMethod,
    0, // int startX
    0, // int startY
    bmp.bmWidth, // int width
    bmp.bmHeight, // int height
    rgbArray, // int[] rgbArray
    0, // int offset
    bmp.bmWidth); // int scansize
    // Free stuff
    (*env)->DeleteLocalRef(env, rgbArray);
    free(charArray);
    free(intArray);
    return jImage;
    }I already tried working with native HDCs (GetDC, CreateCompatibleBitmap, SelectObject, GetDIBits, ...) but this just complicates stuff and gives me the same result.

    Have you verified what the "native DLL" gives you back on the second call?The HBITMAP handle returned is the same each call (no matter which thread). The actual BITMAP associated with this handle is only updated in the first thread.
    How are you determining that the image is the same?If I point the camera (I don't get a stream, I just get individual images) to a moving scene, I get different images for each call from within the first thread. The second thread only gets the latest image from the first thread. There is no concurrency of the threads and all methods are synchronized.
    Specifically did you verify that the problem is not that your test code itself is using the same instance?Yes, I tested the native side as well as the Java side. The BufferedImage is always an exact copy of the native BITMAP.
    Try printing out the hash for each instance.I have written the image to a file in the native code itself to eliminate anything related to the mechanism of returning the BufferedImage. This had the same result.
    The return values of all native calls all indicate successful calls.
    I am suspecting the native side of creating a second graphical context for the second thread while it keeps refering to the first context.
    (I will start a thread on the MSDN as well and will post here if anything turns up.)

  • Calling back c++ method in an exe (not a dll) from java?

    Hi all,
    I have to make an hybrid C++/java from an existing C++
    application that compiled is a big single exe not a dll.
    I'm running under win32.
    The application consists of several windows. The hybrid
    will have widows in C++ and some in java. They have the
    same menu and tool bar. In the C++, there are some
    callbacks called when a button is pressed. How to call
    these callback from java given the fact that the JVM and
    the java classes are launched by the exe file.
    I know how, from C++, start JVM and call my java window.
    I also know how to call a C++ method that is in a dll from
    java. It's from the tutorial
    http://java.sun.com/docs/books/tutorial/native1.1/index.html
    But I don't know how to call a C++ method that is in in an
    exe which has launch a JVM from an object running in this
    JVM.
    Is there somewhere an example like this?
    Thanks,
    Xavier.

    Thanks this helped.
    For those who want a complete example, here it is:
    Tested on XP, java 1.4.2, VC++ 6.0.
    ************ File invoke.cpp *****************************
    #include <stdlib.h>
    #include <jni.h>
    #ifdef _WIN32
    #define PATH_SEPARATOR ';'
    #else /* UNIX */
    #define PATH_SEPARATOR ':'
    #endif
    #define USER_CLASSPATH "." /* where Prog.class is */
    void JNICALL displayHelloWorld(JNIEnv *env, jobject obj)
        printf("Hello world: made by printf from C++\n");
        return;
    void main() {
        JNIEnv *env;
        JavaVM *jvm;
        JavaVMInitArgs vm_args;
        jint res;
        jclass cls;
        jmethodID mid;
        jstring jstr;
        jobjectArray args;
        char classpath[1024];
         int result;
        /* IMPORTANT: specify vm_args version # if you use JDK1.1.2 and beyond */
         JavaVMOption options[3];
         options[0].optionString = "-verbose:gc";
         sprintf (classpath, "-Djava.class.path=%s", USER_CLASSPATH);
         options[1].optionString = classpath;
         options[2].optionString = "-Djava.compiler=NONE";
         vm_args.options = options;
         vm_args.nOptions = 3;
         vm_args.ignoreUnrecognized = JNI_TRUE;
            vm_args.version = JNI_VERSION_1_4;
         /* IMPORTANT: Note that in the Java 2 SDK, there is no longer any need to call
          * JNI_GetDefaultJavaVMInitArgs. It causes a bug
        /* Append USER_CLASSPATH to the end of default system class path */
        /* Create the Java VM */
        res = JNI_CreateJavaVM(&jvm,(void**)&env, &vm_args);
        if (res < 0) {
            fprintf(stderr, "Can't create Java VM\n");
            exit(1);
        cls = env->FindClass("mypackage/Prog");
        if (cls == 0) {
            fprintf(stderr, "Can't find mypackage/Prog class\n");
            exit(1);
       JNINativeMethod nm;
       nm.name = "displayHelloWorld";
       /* method descriptor assigned to signature field */
       nm.signature = "()V";
       nm.fnPtr = displayHelloWorld;
       env->RegisterNatives(cls, &nm, 1);
        mid = env->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V");
        if (mid == 0) {
            fprintf(stderr, "Can't find Prog.main\n");
            exit(1);
        jstr = env->NewStringUTF(" from C++! calleded by C++, using argument from C++ but java method");
        if (jstr == 0) {
            fprintf(stderr, "Out of memory\n");
            exit(1);
        args = env->NewObjectArray(1,
                            env->FindClass("java/lang/String"), jstr);
        if (args == 0) {
            fprintf(stderr, "Out of memory\n");
            exit(1);
        env->CallStaticVoidMethod(cls, mid, args);
        jvm->DestroyJavaVM();
    }********************* File ./mypackage/Prog.java **************************
    package mypackage;
    public class Prog {
           public native void displayHelloWorld();
        public static void main(String[] args) {
            System.out.println("Hello World" + args[0] +"\n");
            Prog prog = new Prog();
            prog.displayHelloWorld();
            System.out.println("(called from java)");
            System.out.println("\nSo to sumurize:");
            System.out.println(" -1 Starting point is an exe (not DLL, there is no DLL) so C++ code");
            System.out.println(" -2 From C++ call java method using argument from C++");
            System.out.println(" -3 From java, that was launched by the exe, call to");
            System.out.println("    a native using the RegisterNatives in C++\n");
            System.out.println("You got a bidirectional example with as starting point");
            System.out.println("a single exe, launching JVM, loading class call back C++!");
    }******************* Command line for all ****************************************
    javac mypackage/Prog
    cl -I"D:\Program Files\j2sdk1.4.2_03\include" -I"D:\Program Files\j2sdk1.4.2_03\include\win32" -MT
    invoke.cpp -link D:\PROGRA~1\j2sdk1.4.2_03\lib\jvm.lib
    (Remark, the last path is using the short name for "Program Files" because with the blank
    even adding double quotes result into an error)
    You must have jvm.dll in your path for me it's Path=D:\Program Files\j2sdk1.4.2_03\jre\bin\client;
    Then simply call invoke and see the result. :-)

  • Accessing DLL in Java doesn't work - really it DOESN'T !!!

    Hi,
    I've got big troubles accessing a DLL in Java - almost for one week !!!
    I want to call some methods from the LDCNLIB.DLL (www.logosolinc.com -> Software)
    First, I tried to access the file via JNI ->
    Exception in thread "main" java.lang.UnsatisfiedLinkError: LdcnInit
    at Test.LdcnInit(Native Method)
    at Test.main(Test.java:11)
    Of Course, the DLL is loaded, everything seems fine.
    I tried to create header files, I tried SWIG, JNIWrapper, JACE, JAWIN, ... Nothing!!!
    I just want to call this method: "int count = LdcnInit("COM1", 19200);"
    Can anybody help me? Please (don't be angry with me), just tell me what to do, no links to tutorials or documentations - I ALREADY READ THEM ALL!!!
    Thanks
    Torsten

    Hi,
    I had no problem at all to access this lib with JNative.
    Here is a sample code.
    package org.xvolks.test.Ldcnlib;
    import org.xvolks.jnative.JNative;
    import org.xvolks.jnative.Type;
    import org.xvolks.jnative.exceptions.NativeException;
    public class Test {
         public static void main(String[] args) throws NativeException, InterruptedException, IllegalAccessException {
    //          System.setProperty("jnative.loadNative", "E:\workspace\JNativeCpp\Win32_Release\libJNativeCpp.dll")
              for(String s : JNative.getDLLFileExports("C:\\Documents and Settings\\Administrateur\\Bureau\\ldcnlib\\Ldcnlib.dll")) {
                   System.err.println(s);
              System.load("C:\\Documents and Settings\\Administrateur\\Bureau\\ldcnlib\\Ldcnlib.dll");
              JNative LdcnInit = new JNative("Ldcnlib.dll", "LdcnInit");
              LdcnInit.setRetVal(Type.INT);
              LdcnInit.setParameter(0, "COM1");
              LdcnInit.setParameter(1, 19200);
              LdcnInit.invoke();
              System.err.println("LdcnInit returned "+LdcnInit.getRetValAsInt());
    }The output was as expected :
    AddArcSeg
    AddLineSeg
    AddPathPoints
    ClearSegList
    FixSioError
    GetComPort
    GetSioError
    IOSynchOutput
    InitPath
    IoBitDirIn
    IoBitDirOut
    IoClrOutBit
    IoGetADCVal
    IoGetBitDir
    IoGetOutputs
    IoGetPWMVal
    IoGetStat
    IoGetTimerMode
    IoGetTimerSVal
    IoGetTimerVal
    IoInBitSVal
    IoInBitVal
    IoOutBitVal
    IoSetOutBit
    IoSetOutputs
    IoSetPWMVal
    IoSetSynchOutput
    IoSetTimerMode
    IsBusy
    LdcnChangeBaud
    LdcnDefineStatus
    LdcnFullInit
    LdcnGetGroupAddr
    LdcnGetModType
    LdcnGetModVer
    LdcnGetStat
    LdcnGetStatItems
    LdcnGroupLeader
    LdcnHardReset
    LdcnInit
    LdcnNoOp
    LdcnReadStatus
    LdcnResetDevice
    LdcnRestoreNetwork
    LdcnSendCmd
    LdcnSetGroupAddr
    LdcnShutdown
    LdcnSynchInput
    MaxStepPeriod
    MinStepPeriod
    PathGetVelocity
    PathTime
    SegmentsInBuffer
    ServoAddPathPoints
    ServoClearBits
    ServoEEPROMCtrl
    ServoGetAD
    ServoGetAD10
    ServoGetAux
    ServoGetCmdAcc
    ServoGetCmdAdc
    ServoGetCmdAdc10
    ServoGetCmdPos
    ServoGetCmdPwm
    ServoGetCmdVel
    ServoGetGain
    ServoGetHome
    ServoGetHomeCtrl
    ServoGetInport1
    ServoGetInport2
    ServoGetInport3
    ServoGetIoCtrl
    ServoGetMoveCtrl
    ServoGetNPoints
    ServoGetOutport1
    ServoGetOutport2
    ServoGetOutport3
    ServoGetOutport4
    ServoGetPError
    ServoGetPos
    ServoGetSDMode
    ServoGetServoInit
    ServoGetStat
    ServoGetStopCtrl
    ServoGetVel
    ServoInitPath
    ServoLoadTraj
    ServoLoadTraj10
    ServoResetPos
    ServoResetRelHome
    ServoSetFastPath
    ServoSetGain
    ServoSetHoming
    ServoSetOutputs
    ServoStartMotion
    ServoStartPathMode
    ServoStopMotor
    SetFeedrate
    SetOrigin
    SetPathParams
    SetTangentTolerance
    SimpleMsgBox
    SioChangeBaud
    SioClose
    SioClrInbuf
    SioGetChars
    SioOpen
    SioPutChars
    SioTest
    StepGetAD
    StepGetCmdAcc
    StepGetCmdPos
    StepGetCmdST
    StepGetCmdSpeed
    StepGetCtrlMode
    StepGetEmAcc
    StepGetHoldCurrent
    StepGetHome
    StepGetHomeCtrl
    StepGetIObyte
    StepGetInbyte
    StepGetMinSpeed
    StepGetMvMode
    StepGetOutputs
    StepGetPos
    StepGetRunCurrent
    StepGetStat
    StepGetStepPeriod
    StepGetStepTime
    StepGetStopCtrl
    StepGetThermLimit
    StepLoadTraj
    StepLoadUnprofiledTraj
    StepResetPos
    StepSetHoming
    StepSetOutputs
    StepSetParam
    StepStopMotor
    StepTime2StepsPerSec
    StepsPerSec2StepTime
    StepsPerSec2mSecPerStep
    ___CPPdebugHook
    mSecPerStep2StepsPerSec
    LdcnInit returned 0--Marc (http://jnative.sf.net)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Invoking Bpel Process from JAVA

    Hi I am new to BPEl.
    I am trying to Invoke Bpel From Java client provided in samples...
    i am getting
    java.lang.NullPointerException
    at this line..
    Map payload = res.getPayload();
    The Bpel Process is on my local machine...
    i kept the properties file as it is....
    Can any one Respond please.....

    Hi
    now i am getting this exception
    java.lang.Exception: Failed to create "ejb/collaxa/system/DomainManagerBean" bean; exception reported is: "javax.naming.NamingException: Lookup error: java.lang.NoClassDefFoundError: javax/servlet/http/HttpSessionContext; nested exception is:
         java.lang.NoClassDefFoundError: javax/servlet/http/HttpSessionContext [Root exception is java.lang.NoClassDefFoundError: javax/servlet/http/HttpSessionContext]
         at com.evermind.server.rmi.RMIContext.lookup(RMIContext.java:168)
         at javax.naming.InitialContext.lookup(InitialContext.java:347)
         at com.oracle.bpel.client.util.BeanRegistry.lookupDomainManagerBean(BeanRegistry.java:218)
         at com.oracle.bpel.client.auth.DomainAuthFactory.authenticate(DomainAuthFactory.java:83)
         at com.oracle.bpel.client.Locator.<init>(Locator.java:140)
         at com.oracle.bpel.client.Locator.<init>(Locator.java:111)
         at com.otn.samples.RMIClient.main(RMIClient.java:49)
    Caused by: java.lang.NoClassDefFoundError: javax/servlet/http/HttpSessionContext
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
         at java.lang.Class.getDeclaredMethods0(Native Method)
         at java.lang.Class.privateGetDeclaredMethods(Class.java:1655)
         at java.lang.Class.getDeclaredMethod(Class.java:1262)
         at java.io.ObjectInputStream$1.run(ObjectInputStream.java:1198)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.io.ObjectInputStream.auditSubclass(ObjectInputStream.java:1190)
         at java.io.ObjectInputStream.verifySubclass(ObjectInputStream.java:1171)
         at java.io.ObjectInputStream.<init>(ObjectInputStream.java:248)
         at com.evermind.io.ClassLoaderObjectInputStream.<init>(ClassLoaderObjectInputStream.java:16)
         at com.evermind.server.ejb.EJBInputStream.<init>(EJBInputStream.java:35)
         at com.evermind.server.rmi.RMIInputStream.<init>(RMIInputStream.java:20)
         at com.evermind.server.rmi.RMIConnection.createInputStream(RMIConnection.java:2417)
         at com.evermind.server.rmi.RMIConnection.connect(RMIConnection.java:2555)
         at com.evermind.server.rmi.RMIConnection.connect(RMIConnection.java:2361)
         at com.evermind.server.rmi.RMIConnection.lookup(RMIConnection.java:1800)
         at com.evermind.server.rmi.RMIServer.lookup(RMIServer.java:676)
         at com.evermind.server.rmi.RMIContext.lookup(RMIContext.java:149)
         ... 6 more
    can you say how to fix this...

  • How to run 64-bit native code with Java Web Start

    This question has probably been asked many times, but I couldn't find anything in my searches.
    How can I get Java Web Start on a Solaris client (Solaris 10 in this case, with JRE 1.5) to run a java application that includes a 64-bit native code library? The application downloads fine, including the jar file that has the native shared object, but when the native library is loaded by the java application, I get a "wrong ELF class: ELFCLASS64" error.
    I assume that is because Web Start is invoking the 32-bit java VM, which can't load a 64-bit library. I tried configuring Java Web Start to use the 64-bit VM (by setting the path to java to ".../jre/bin/sparcv9/java" in the javaws console) but then I get an error that says "Can't load library: .../jre/lib/sparcv9/libdeploy.so".
    Does Java Web Start support 64-bit native code, and if so, what do I need to do differently?
    Thanks.

    No it can't. On the Sun download page of the JRE it says that 64 Bit systems need to use the 32 Bit JRE to execute Plugins - this might be the same for Web Start apps.

  • Error when invoking Rule Engine using Java API

    Hi,
    I have implemented a Java class which calls the Rule Engine to execute the rules. If I test by setting the value of the input inside a main method and get the output, it is working fine. The ruleset is also invoked and there is no problem. However, when I expose this java class as a web service and invoke the web service, I get the below error. I dont get the error if the .rules file is not present in the loaction mentioned. I get the error when the .rules file is present in the location. Not sure if this is an issue with the java call outs or loading the dictionary.
    Error:_
    <faultcode>S:Server</faultcode>
    <faultstring>oracle/rules/sdk2/exception/SDKException</faultstring>
    <ns2:exception xmlns:ns2="http://jax-ws.dev.java.net/" note="To disable this feature, set com.sun.xml.ws.fault.SOAPFaultBuilder.disableCaptureStackTrace system property to false" class="java.lang.NoClassDefFoundError">
    <message>oracle/rules/sdk2/exception/SDKException</message>
    <ns2:stackTrace>
    <ns2:frame line="38" file="ImplementRules.java" method="Query" class="oracle.rules.querystudentcriteria.ImplementRules"/>
    <ns2:frame line="native" file="NativeMethodAccessorImpl.java" method="invoke0" class="sun.reflect.NativeMethodAccessorImpl"/>
    <ns2:frame line="39" file="NativeMethodAccessorImpl.java" method="invoke" class="sun.reflect.NativeMethodAccessorImpl"/>
    <ns2:frame line="25" file="DelegatingMethodAccessorImpl.java" method="invoke" class="sun.reflect.DelegatingMethodAccessorImpl"/>
    <ns2:frame line="597" file="Method.java" method="invoke" class="java.lang.reflect.Method"/>
    <ns2:frame line="101" file="WLSInstanceResolver.java" method="invoke" class="weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker"/>
    <ns2:frame line="83" file="WLSInstanceResolver.java" method="invoke" class="weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker"/>
    <ns2:frame line="152" file="InvokerTube.java" method="invoke" class="com.sun.xml.ws.server.InvokerTube$2"/>
    <ns2:frame line="264" file="EndpointMethodHandler.java" method="invoke" class="com.sun.xml.ws.server.sei.EndpointMethodHandler"/>
    <ns2:frame line="93" file="SEIInvokerTube.java" method="processRequest" class="com.sun.xml.ws.server.sei.SEIInvokerTube"/>
    <ns2:frame line="604" file="Fiber.java" method="__doRun" class="com.sun.xml.ws.api.pipe.Fiber"/>
    <ns2:frame line="563" file="Fiber.java" method="_doRun" class="com.sun.xml.ws.api.pipe.Fiber"/>
    <ns2:frame line="548" file="Fiber.java" method="doRun" class="com.sun.xml.ws.api.pipe.Fiber"/>
    <ns2:frame line="445" file="Fiber.java" method="runSync" class="com.sun.xml.ws.api.pipe.Fiber"/>
    <ns2:frame line="275" file="WSEndpointImpl.java" method="process" class="com.sun.xml.ws.server.WSEndpointImpl$2"/>
    <ns2:frame line="454" file="HttpAdapter.java" method="handle" class="com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit"/>
    <ns2:frame line="250" file="HttpAdapter.java" method="handle" class="com.sun.xml.ws.transport.http.HttpAdapter"/>
    <ns2:frame line="140" file="ServletAdapter.java" method="handle" class="com.sun.xml.ws.transport.http.servlet.ServletAdapter"/>
    <ns2:frame line="319" file="HttpServletAdapter.java" method="run" class="weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke"/>
    <ns2:frame line="232" file="HttpServletAdapter.java" method="post" class="weblogic.wsee.jaxws.HttpServletAdapter"/>
    <ns2:frame line="310" file="JAXWSServlet.java" method="doPost" class="weblogic.wsee.jaxws.JAXWSServlet"/>
    <ns2:frame line="727" file="HttpServlet.java" method="service" class="javax.servlet.http.HttpServlet"/>
    <ns2:frame line="87" file="JAXWSServlet.java" method="service" class="weblogic.wsee.jaxws.JAXWSServlet"/>
    <ns2:frame line="820" file="HttpServlet.java" method="service" class="javax.servlet.http.HttpServlet"/>
    <ns2:frame line="227" file="StubSecurityHelper.java" method="run" class="weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction"/>
    <ns2:frame line="125" file="StubSecurityHelper.java" method="invokeServlet" class="weblogic.servlet.internal.StubSecurityHelper"/>
    <ns2:frame line="292" file="ServletStubImpl.java" method="execute" class="weblogic.servlet.internal.ServletStubImpl"/>
    <ns2:frame line="26" file="TailFilter.java" method="doFilter" class="weblogic.servlet.internal.TailFilter"/>
    <ns2:frame line="56" file="FilterChainImpl.java" method="doFilter" class="weblogic.servlet.internal.FilterChainImpl"/>
    <ns2:frame line="326" file="DMSServletFilter.java" method="doFilter" class="oracle.dms.wls.DMSServletFilter"/>
    <ns2:frame line="56" file="FilterChainImpl.java" method="doFilter" class="weblogic.servlet.internal.FilterChainImpl"/>
    <ns2:frame line="3592" file="WebAppServletContext.java" method="run" class="weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction"/>
    <ns2:frame line="321" file="AuthenticatedSubject.java" method="doAs" class="weblogic.security.acl.internal.AuthenticatedSubject"/>
    <ns2:frame line="121" file="SecurityManager.java" method="runAs" class="weblogic.security.service.SecurityManager"/>
    <ns2:frame line="2202" file="WebAppServletContext.java" method="securedExecute" class="weblogic.servlet.internal.WebAppServletContext"/>
    <ns2:frame line="2108" file="WebAppServletContext.java" method="execute" class="weblogic.servlet.internal.WebAppServletContext"/>
    <ns2:frame line="1432" file="ServletRequestImpl.java" method="run" class="weblogic.servlet.internal.ServletRequestImpl"/>
    <ns2:frame line="201" file="ExecuteThread.java" method="execute" class="weblogic.work.ExecuteThread"/>
    <ns2:frame line="173" file="ExecuteThread.java" method="run" class="weblogic.work.ExecuteThread"/>
    </ns2:stackTrace>
    The Java class looks like:
    public PersonType Query (PersonType p)
    try {
    //FileReader reader = new FileReader("/home/orasoa/223345/STRS1.rules");
    //FileReader reader = new FileReader("D:\\Arun\\NGCE_WS\\POC1\\UHG\\QueryStudentCriteria\\oracle\\rules\\querystudentcriteria\\STRS1.rules");
    InputStream stream=ImplementRules.class.getResourceAsStream("/STRS1.rules");
    Reader reader=new InputStreamReader(stream);
    RuleDictionary dict = RuleDictionary.readDictionary(reader, new DecisionPointDictionaryFinder(null));
    List<SDKWarning> warnings = new ArrayList<SDKWarning>();
    dict.update(warnings);
    DecisionPoint decisionPoint = new DecisionPointBuilder().with("STRS1_DecisionService_1").with(dict).build();
    DecisionPointInstance point = decisionPoint.getInstance();
    ArrayList input=new ArrayList();
    input.add(p);
    point.setInputs(input);
    List<Object> output=point.invoke();
    catch (Exception e) {}
    return p;
    Cheers,
    - AR

    Hi, I am getting a similar error when I deploy my application on the weblogic server.
    Could you detail how this was resolved?
    Thanks,
    SB

  • How can i pass string from C++ DLL to Java via JNI?

    Hi everybody. I made a DLL with Borland C++. I must pass a string from this dll to Java via JNI.Namely i define a string variable in C++ DLL and i send this variable's value to Java via JNI.
    I can pass integers but i couldnt Strings. . How can i do this? is there any sample?

    Hi,
    So your function should be private static native String get_text();
    (It's often a good idea to make native methods private since when you change signatures you generally have to change java wrapper methods only).
    I know nothing about C++ strings but I'm pretty sure that you can convert it to char*, so
    do :
    char* szMyString = myString.toChar*();
    Then return from native with JNU_NewStringPlatform(env, szMyString)
    (see my 1st answer for JNU_NewStringPlatform() description).
    --Marc (http://jnative.sf.net)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to call VB dlls in java

    Hi
    I created one component in vb, where this component got 3 methods. and created dll also, when iam trying to use these dlls in java. it showing error, is there any method to call the vb dlls in java(native method), if s pls help me to solve these problem.

    hi, all
    I writed a vb dll, It have three publice sub and one preporty,
    I use html <object> attribute to declare this dll and call its methods and perporty in html file, everything is ok.the source code as following:
    <body>
    <OBJECT declare id="repExport" classid="clsid:0487D845-0DAD-46D0-9559-FADEC117C2B9">
    <param name="Exportfile" value="peiru">
    </OBJECT>
    <script language="vbscript">
    repExport.Exportfile="peiruyt"
    repExport.CrystalConnect()
    repExport.PassParameterRtp()
    repExport.reportexport()
    </script>
    Because i need get parameter from other web page , and i use weblogic 6.1 server, so i need change file type from html to jsp , But even if I just change the file extension from html to jsp, don't change any content in this file.
    then jsp cannot work, error message is "object don't support 'repExport.Exportfile' property", actual it don't support all three functions and a property
    Can anyone provide any help?
    thanks
    peiru

  • Calling DLLs in JAVA

    Hi,
    I need to create a utility for a component in a 3rd party tool. I am planning to create this utility in JAVA. But the problem is that the 3rd party tool uses DLLs which is created in VB 6.0 (Its seems so).
    I came across the key word "NATIVE" in JDK. But the examples related to this is all given for C/C++. I am not sure whether following the same procedure we will be able to access any VB dlls.
    Please help me out. I am aware that there are ceratin APIs which we can use as a Bridge between Dlls and Java. And If I am right one among such is JACOB. But I am trying to minimize the dependencies of my Java Code to any other Utilities.
    Eagerly waiting for a valuable Advice
    Jiju Jagadish

    Hi,
    It seems you'll need to compile you own DLL wrapper if you do not want to depend on 3rd party library, search for JNI spec here.
    On the other hand generic wrappers save time, if you are not famillar with C/C++.
    Look at that post : http://forum.java.sun.com/thread.jspa?threadID=722211&tstart=0
    --Marc (http://jnative.sf.net)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Calling dll in Java using The JACOB Project

    Hi I'm trying to import and read the class and methods from a DotNet API (dll) in java code usind the Jacon Project does anybody know how to do it? (like and example or simple staps to have an idea)
    thanks
    Luca

    afaik you cannot call windows API functions directly, you have to create a 'wrapper' method in C++ in order to access the API functions.
    it will look something like
    // Java code:
    package a.b;
    class Thingie {
      public native int doThatFunkyThingie();
    // c++ code
    jint Java_a_b_Thingie_doThatFunkyThingie(JNIEnv *env, JObject j) {
      // c++ function calls go here
    }I haven't done JNI in over a year, so this is probably not entirely correct.
    I recommend you read the JNI tutorial.
    J

Maybe you are looking for