JNI calls in an Applet

Hi all,
I have an applet that makes an JNI call to a DLL. The DLL is in a custom directory c:\testing\test.dll. Under the default JDK that ships with Windows 2000 it works fine when I do a
System.loadLibrary("c:/testing/test");
However, I've switch to the JDK 1.3 plugin and now I get an UnsatisfiedLinkError. If I move the file to c:\winnt\system32, it works fine. I've tried setting the "java.library.path" property to no avail.
Anyone have any ideas, besides moving the dll to c:\winnt\system32?
thx.
Mike

the solution was to use System.load instead of System.loadLibrary

Similar Messages

  • I am using a Application in c dll calling from jni jar by java applet in firefox version 19.0 , the problem is click event message box will not working correct

    I am using a Application in c dll calling from jni jar by java applet in firefox version 19.0 , the problem is button click event message box or popup window will not working correctly. Please any one suggest me the steps to overcome this not responding or slowness in the responding problem of Button click event.

    Hello,
    In Firefox 23, as part of an effort to simplify the Firefox options set and protect users from unintentially damaging their Firefox, the option to disable JavaScript was removed from the Firefox Options window.
    However, the option to disable JavaScript was not removed from Firefox entirely. You can still access it from about:config or by installing an add-on.
    '''about:config'''
    # In the address bar, type "about:config" (with no quotes), and press Enter.
    # Click "I'll be careful, I promise"
    # In the search bar, search for "javascript.enabled" (with no quotes).
    # Right click the result named "javascript.enabled" and click "Toggle". JavaScript is now disabled.
    To Re-enable JavaScript, repeat these steps.
    '''Add-ons'''
    You can alternatively install an add-on that lets you disable JavaScript, such as
    *[https://addons.mozilla.org/firefox/addon/noscript/ No-Script] (to disable JavaScript on a per page basis, as required)
    *[https://addons.mozilla.org/firefox/addon/quickjava/ QuickJava] (to easily disable and enable JavaScript, automatic loading of images, and other content)
    Thank you and I hope this helps!

  • How do you use a main applet to call other child applets?

    Hello Everyone!
    I have created three separate applets that animate different colored walkers that walk across the web page with each applet doing what I need them to do. I need to create a main applet that displays a component that allows the user to select how many walkers(1-3) they would like to see displayed walking across the screen. The main applet should call only one walker applet if 1 is selected, call two applets if 2 is selected, or call all three applets if 3 is selected.
    My textbook has covered how to call other classes in an application but not a main applet calling other applets. I have gone through the tutorials but have not found anything related to what I need to do. Google didn't have any good ideas.
    Another possibility that would work would be to have one applet with each walker having its own method to be called based upon the selection. Then again, my textbook didn't cover calling methods within an applet.
    Any hints or suggestions would be greatly appreciated on these issue.
    Thanks.
    Unclewho

    Remember, an Applet is nothing more than a Panel (or JPanel for a JApplet) - basically an empty graphics container waiting for UI or graphics commands.
    You do not have a "main" applet as you do when you create an executable application which requires the 'main' method.
    The best thing to do, is simply do an HTTP Redirect to a page created with the desired number of "walkers". In your cause, the most you'd need is 3 walkers, so 4 pages - 1 redirect page, and then a page with 1 walker, a page with 2 walkers, and a page with 3 walkers.

  • How can I display the HTML page from servlet which is called by an applet

    How can I display the HTML page from servlet which is called by an
    applet using the doPost method. If I print the response i can able to see the html document. How I can display it in the browser.
    I am calling my struts action class from the applet. I want to show the response in the same browser.
    Code samples will be appreciated.

    hi
    I got one way for this .
    call a javascript in showDocument() to submit the form

  • Wildcards in Classpath for JNI-Calls

    Is it possible to use wildcards in the classpath for KNI-Calls?
    I would like to use wildcard for jni-calls like for normal java-calls (java -classpath *.jar ...), but it is not working.
    JDK version is JDK 1.5.0 on Win32

    I would like to use wildcard for jni-calls like for normal
    java-calls (java -classpath *.jar ...), but it is not working.It would be the Shell, not Java doing the wildcard magic.
    You would have to do the globbing manually (or use any OS APIs, or 3rd party APIs).

  • JNI Calling Java code when attaching to existing JVM

    I've got an Active/X that runs within IE, and also makes JNI calls (via the Invocation API) to Java code. Running within IE means there's already a JVM around, so I attach to it using JNI_GetCreatedJavaVMs
    This is fine. The problem is that I can't use the JNI findClass() to locate my Java classes, because I have no control over the classpath that the JVM is using to locate classes. The only solution I can think of so far is to either add my classes as part of the JVM, OR find out the classpath of the existing JVM (using System.getProperty("java.class.path") and copy my classes into that directory.
    Both solutions look ugly - anyone know of a cleaner way ?
    Mark.

    Toby, thanks for the reply.
    You're welcome.
    I notice from elsewhere on this forum, you're clearly a JNI expert.
    I've been known to work with it a little from time to time. =)
    My code has to work with JDK 1.1 so URLClassLoader is out. Writing my own classloader is fine, but how do I load it in the first place ? Is there something in JNI I've missed ?
    Possibly. Using DefineClass() you can load a class into the virtual machine, given it's byte-code. Now here's the tricky part. First, write your ClassLoader. It will be easiest if it doesn't rely on any other classes other than what is core to the JRE. Once you compile that classloader, you then need to include the bytecode as a resource in your executable/dll. Then, at runtime, you can load that resource, and use DefineClass to class-load it. Once you've class-loaded it, you can use NewObject, GetMethodID, CallXXXMethod, etc... to do the other class loading you need to do.
    Trust me, this really isn't as hard as it might sound.
    God bless,
    -Toby Reyelts
    As always, I recommend you check out the free, open-source JNI toolkit, Jace, at http://jace.reyelts.com/jace.

  • Core dump on solaris 8/7 making JNI call.

    Hi,
    I am running solaris 8 and solaris 7 with Java 1.3.1. I have required solaris patches installed on the machine for java 1.3.1.
    From a C program I am making some JNI calls and when I run the program it core dumps at the very first JNI call. C program that make JNI calls are in a .so file.
    Same C code with Java 1.3.1 is running fine on window 2000, AIX 5.1, RedHat Advanced Server 2.1 and SuSE Enterprise Linux 7.
    Any help will be greatly appriciated.
    Thanks

    Hiya,
    Any resolution to this post , we have a native JNI call on a Websphere server running on Solaris 8 .. and same thing happening .. random core dump on the box ..
    No warning , no explanation
    Thanks so much for your help
    (btw . running Sun jvm 1.4.2_13)

  • Local ref garbage collection within "nested" JNI calls

    I am using a JVM started in C++ to make calls to java classes. The C++ code makes JNI call into the JVM which instantiates a java class. The java class, in the course of execution, makes other JNI calls. All this happens on one thread of execution.
    What I am seeing is that local references from the native methods being called by the java class are not being released until the initial C++ native call exits. The JNI spec (text included below) seems to indicate there is registry of "nonmovable local references to Java objects" which "keeps the objects from being garbage collected". Is there only one such registry which does not get deleted until the initial C++ native call exits? If so, this would explain what I am seeing. How do I get around it?
    Thanks,
    Iztok
    From the JNI spec:
    "To implement local references, the Java VM creates a registry for each
    transition of control from Java to a native method. A registry maps nonmovable local references to Java objects, and keeps the objects from being garbage collected. All Java objects passed to the native method (including those that are returned as the results of JNI function calls) are automatically added to the registry. The registry is deleted after the native method returns, allowing all of its entries to be garbage collected."

    When I say "initial" I mean the initial C++ JNI call into a JVM running in a C++ process as shown in the pseudo code below. initNativeFunc() makes a call to Foo.doSomething() function which calls nativeFunc2 (another native function). Only a local reference to Retval was created in nativeFunct2, so when nativeFunct2 returns and the Retval is no longer used in Foo it should be a candidate for garbage collection. But this is not what happens. The Retval from nativeFunc2 is not being cleaned up until Foo.doSomething() returns. If I make the loop in Foo.doSomething() long enough, NewDoubleArray() returns a NULL when it runs out of memory.
    void initNativeFunc() {
    jclass clazz = env->FindClass("Foo");
    jmethodID mid = env->GetMethodID(clazz, "doSomething", "()V");
    env->CallVoidMethod(clazz, mid, ...);
    JNIEXPORT jobject JNICALL nativeFunc2() {
    jclass clazz = env->FindClass("Retval");
    jmethodID mid = env->GetMethodID("Retval, "<init>", "()V");
    jobject retval= env->NewObject(clazz, mid);
    jdoubleArray da = env->NewDoubleArray(100000);
    jfieldID fid = ...
    env->SetObjectField(retval, fid, da);
    return retval;
    public class Foo {
    public native void nativeFunc2();
    public void doSomething() {
    for (int i = 0; i < 100; i++) {
    Retval retval = nativeFunc2();
    }

  • Classpath for JNI call in NT4?

    ?I prepare MyClass for JNI call on iPlanet 6 running on NT. The corresponding DLL is put in WINNT\SYSTEM32. The classpath set in registry is updated too. But error "class not found. (no MyClass in java.library.path)" still occurs. Is there any work i miss? Please advise.?

    Hi,
    Can you check the Environment variable CLASSPATH ?, the application server's classpath found under Software/iPlanet->Application Server->6.0->Java using kregedit.
    Thanks & Regards
    Ganesh .R
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support

  • Stack overflow in JNI call

    Hi,
    I am doing a wrapper with JNI for a Windows library of image compression. I have a test program running correctly in C. This program compress data and it can move a lot of memory. If I call this program from a JNI functions I obtain a JNI error:
    An unrecoverable stack overflow has occurred.
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : EXCEPTION_STACK_OVERFLOW (0xc00000fd) occurred at PC=0x5FF88497
    Function=unpack_data+0x189D7
    Library=C:\WINDOWS\system32\NCSEcw.dll
    This error is produce inside my compression library. I try to adjust the parameters (-Xms -Xmx -Xss) of the JVM but in any case before the process ends it shows this exception. I have done other JNI interfaces and I never found with this problem before. Can anybody help me?
    Thanks in advance.

    I found in this forum a piece of code with a same kind problem but It is simpler than mine. I have proved this program in Windows and it produce the same error. In Linux it runs but if I enlarge the array largebuf it ends with the same error. In Linux I can reserve until 2 MB (in windows +-256K). Is there any way to increase the stack size in a jni call?.
    #include <stdio.h>
    #include <jni.h>
    #include "test.h"
    int myprint2(int a, int b){
         char extrabuf[100];
         printf("got here next\n");
         extrabuf;
         return 0;
    int myprint(int a, int b){
         char largebuf[260000];
         printf("got here\n");
         myprint2(1,1);
         largebuf;
         return 0;
    JNIEXPORT jint JNICALL Java_test_init(JNIEnv *env, jobject obj){
         myprint(1,1);
         return 1;
    test.java
    public class test{
         public native int init();
         public static void main(String []args){
              new test();
         public test(){
              System.loadLibrary("Nat");
              System.out.println(this.init());
    }

  • Creating JVM to Make JNI calls

    I am trying to create a JVM to make JNI calls to Java. When I try to link my C++ program with jvm.lib, I am getting following error. Please advise.
    "fatal error LNK1106: invalid file or disk full"
    I am sure the disk is not full.

    What IDE are you using? I am using MS VC++ 5.0 with jdk 1.3 and I got the same error. After trying several things (including recreating my project)I realized that jdk 1.3 was created after VC++ 5.0. So on a wild hunch I installed jdk 1.2.2. I then removed all project referrences to jdk 1.3. Closed all my files. Reopend them. Made sure the jni.h external dependency was pointing to 1.2.2 (you may have to do a build to force it) and then everything linked fine.

  • JNI call CallLongMethod causes gpf

    Hi,
    I am using the JNI call CallLongMethod to return a jlongArray.
    jlongArray itemArray = (jlongArray)env->CallLongMethod(jObjFilterCondition, JavaIDs::_mids[JMETHOD_FI_GETALLVALUES]);
    Here method id is cached and it was retrieved as follows:
    env->GetMethodID (env->FindClass("com/fujitsu/pureweb/valueobjects/FilterItem"), "getAllValues", "()[J");
    After this if I try to call GetLongArrayElements(), it results in gpf. This occurs only in Solaris (compiler used is cc 5.0 and JDK 1.3.1_02. The problem does not occur in Windows.
    What can be possible reason for this?
    *** Interestingly, if I replace CallLongMethod with CallIntMethod, it works!!!!!!
    Regards,
    Harish

    If you are trying to get a reference to an array, then you are using the wrong JNI subroutine. An array is an object, and you have to use CallObjectMethod...

  • JNI Calling  a multithreaded C code from Java

    Hi,
    I am new to JNI . I am calling a multithreaded C (in which threads are created at runtime )code from a Java application (swing) on some event . The application crashes and it says "pthreads mutex_lock()". I have added -pthread as a command line argument .But even this does not help although the build is proper .It crashes at runtime .All other JNI calls are working perfectly ...
    Please help .
    Thanks in advance ...
    Regards
    Rohit

    Are any of those threads calling java code? If yes then are you calling the Attach method?

  • JNI call to WIN2K3/OracleAS

    Here is problem faced by one of my collegue, any help is appreciated.
    We are facing problems with handling Oracle 10G AS java security.
    Due to business needs we have to make a JNI call to the underlying OS (Win2K3) and invoke an executable (.EXE). During this call, the App Server hangs the requested executable further killing it using Dr.Watson and taking javaw to 100%. This is observed only in production environment and not in the development environment using JDeveloper. We feel that it is a App Server policy or Sandbox issue.

    Here is problem faced by one of my collegue, any help is appreciated.
    We are facing problems with handling Oracle 10G AS java security.
    Due to business needs we have to make a JNI call to the underlying OS (Win2K3) and invoke an executable (.EXE). During this call, the App Server hangs the requested executable further killing it using Dr.Watson and taking javaw to 100%. This is observed only in production environment and not in the development environment using JDeveloper. We feel that it is a App Server policy or Sandbox issue.

  • Check if applet can load JNI library within the applet

    Hello,
    I have a signed applet that is part of a bigger application. The application has native installer that installs some JNI libraries and grants permissions to my applet in java.policy file. However if the user did not install the application (using the installer) which means that the java.policy file is not modified. Then if he/she go directly go to the web UI, and opens my applet the user sees a dialog with the following warning: "The applet was signed by "xxx", but Java cannot verify the authenticity of the signature's certificate. Do you trust this certificate?" that have two buttons "Trust" and "Don't trust".
    I have two questions:
    A) Is it possible instead of showing the dialog, the JVM directly to choose "Don't trust", which means that I will get a security exception inside my code, so I can navigate to another site with installation instructions.
    B) what is the exact reason for showing this dialog. Is it because I am calling System.loadLibrary("xxx"); which requires privileges. If this is the case, how can I check if the applet has enough privileges before calling System.loadLibrary()?
    Thanks in advance
    Kiril

    A) Is it possible instead of showing the dialog, the JVM directly to choose "Don't trust", which means that I will get a security exception inside my code, so I can navigate to another site with installation instructions.Just don't sign it. It will be totally untrusted, except for clients that have java.policy modified.
    You will get the exception, will catch it and you will be able to navigate to another page from the
    catch block.
    B) what is the exact reason for showing this dialog.The reason is that the applet is signed.
    The reason for the "but..." part is that the certificate was created by a certificate authority that
    Java does not recognize (it would recognize 'well known' CA's like Verisign, Thawte etc.).
    Is it because I am calling System.loadLibrary("xxx"); which requires privileges. If this is the case, how can I check if the applet has enough privileges before calling System.loadLibrary()?Why 'before'? Isn't this good enough?
    try
      System.loadLibrary("xxx");
      // Applet has privileges
    catch ( SecurityException e )
      // Applet does not have privileges
    }

Maybe you are looking for

  • Can anyone help me out with this icon's meaning and how to fix it?

    I just bought a Blackberry Torch 9800.. I have been downloading applications and recently upgraded one of my trial apps to the pro.. but I cannot get the pro version to work. I have activated the account and registered the license key and still nothi

  • Critical Battery alarm needs to be heard, even when muted.

    Hello all and thanks for the support. I have a DV7 w/Vista Home Premium SP2 64-bit that is used for telecommuting. The Citrix app I remotely log into fills the entire screen including the task bar of the local machine with the desktop of the remote m

  • File read write

    Hi guys: its an easy question so i will explain as simply and as elborately as possible: i am reading from a file public void appendFile() {     try {       BufferedReader in = new BufferedReader(new FileReader("temp\\text.txt"));       BufferedWrite

  • Can't Download CS6 upgrade.

    Purchased CS6 upgrade from CS5.  At download screen I got message that my browser must be upgraded to work with macromedia with choice of browser update sites.  I have IE10 on Windows 8 and no upgrades are possible but it won't let me download.  When

  • Help, I messed up permissions for external HDD

    Hi people. Here's the deal. My external 160 GB LaCie-drive (same type of drive that Emmet posted about recently) is divided into two partitions; one that I want to keep public and one that I back-up my private things to. Now I had a whim about permis