FindClass() Problem Pls Help.. (URGENT!!)

Hi,
I trying to use the files from the book "JNI Programmer's Guide & Specifications" - Ch. 7., to create JVM & call a java method from c routine.
I m working on Solaris machine. JVM is 1.1, so the correct part of the version independent code runs (refer to invoke.c below)
LD_LIBRARY_PATH is set correctly. invoke.c is complied correctly with no errors. All the files namely Prog.java, Prog.class, invoke.c, a.out are in the same directoy "/home/top/atm".
When executable file is run. JVM is created. But FindClass() returns with NULL value. !!!
When I try to run Prog.java from the commandline using "java Prog Hello" it runs good.
It just simply won't find the Prog.class in it's current directory. ???
If instead, "java/util/Date" is passed to FindClass(), it finds it.
The classpath in the program is also modified & there is no typo error or case-sensitivity related errors.
I m also printing classpath passed to JVM in the program. It has my included path "/home/top/atm", along with other system classpath(s).
I m banging my head over this problem, since 2 days. Hence I tried to use reference implementation files. It still will not work..
Can anyone pls be patient & help me. I'll really appreciate this.
Thanks a lot,
Following is the code of 2 files..
Prog.java
public class Prog
public static void main(String[] args)
System.out.println("Hello World" + args[0]);
& invoke.c
#include <jni.h>
#define PATH_SEPARATOR ':' /* define it to be ':' on Solaris */
#define USER_CLASSPATH "/home/top/atm" /* where Prog.class is */
main() {
JNIEnv *env;
JavaVM *jvm;
jint res;
jclass cls;
jmethodID mid;
jstring jstr;
jclass stringClass;
jobjectArray args;
#ifdef JNI_VERSION_1_2
JavaVMInitArgs vm_args;
JavaVMOption options[1];
options[0].optionString =
"-Djava.class.path=" USER_CLASSPATH;
vm_args.version = 0x00010002;
vm_args.options = options;
vm_args.nOptions = 1;
vm_args.ignoreUnrecognized = JNI_TRUE;
/* Create the Java VM */
res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
#else
JDK1_1InitArgs vm_args;
char classpath[102400];
vm_args.version = 0x00010001;
JNI_GetDefaultJavaVMInitArgs(&vm_args);
/* Append USER_CLASSPATH to the default system class path */
sprintf(classpath, "%s%c%s",
vm_args.classpath, PATH_SEPARATOR, USER_CLASSPATH);
vm_args.classpath = classpath;
/* Create the Java VM */
res = JNI_CreateJavaVM(&jvm, &env, &vm_args);
fprintf(stderr, "JVM Created !!! with # %d\n", res);
#endif /* JNI_VERSION_1_2 */
if (res < 0) {
fprintf(stderr, "Can't create Java VM\n");
exit(1);
fprintf(stderr, "ClassPath is : %s\n", classpath);
cls = (*env)->FindClass(env, "Prog");
if (cls == NULL) {
goto destroy;
     fprintf(stderr, "Class Found !!\n");
mid = (*env)->GetStaticMethodID(env, cls, "main",
"([Ljava/lang/String;)V");
if (mid == NULL) {
goto destroy;
jstr = (*env)->NewStringUTF(env, " from C!");
if (jstr == NULL) {
goto destroy;
stringClass = (*env)->FindClass(env, "java/lang/String");
args = (*env)->NewObjectArray(env, 1, stringClass, jstr);
if (args == NULL) {
goto destroy;
(*env)->CallStaticVoidMethod(env, cls, mid, args);
destroy:
if ((*env)->ExceptionOccurred(env)) {
(*env)->ExceptionDescribe(env);
(*jvm)->DestroyJavaVM(jvm);
----------------------------------------

Hi , I got the exact same problem as you did. Can you
please let me know if you solve this issue already ?When FindClass returns null it means it threw an exception. The first step is to get that exception and print it out.
The error is probably class not found. And just as with java only that means your class path is not correct.

Similar Messages

  • Classpath problem pls. help urgent

    I have installed jdk1.2, the java files execute only in c:\jdk1.2\bin directory.
    What should I do to run the files in another directory,say c:\glenn
    I have set the classpath by giving the command c:\set classpath=<pathname> but its not working.

    Setting the class path
    http://java.sun.com/j2se/1.2/docs/tooldocs/win32/classpath.html
    Installation notes
    http://java.sun.com/j2se/1.2/install-windows.html
    Jesper

  • Urgent: Sessions problem pls help me

    Hi all,
    Its already late to post this problem.pls help me urgently.
    I have a servlet & two jsp's. first i request servlet, it processes something and forwards request to my first jsp. In that jsp on a button click, i'm displaying a new popup by calling showModalDialog. this dialog gets data from the same servlet but it forwards to my second jsp.(second jsp can be seen in dialog)
    Now if i submit form from my second(dialog) jsp, the servlet reports that session has expired. I tried a lot but invain. any one who helps me is appreciated well by all of our forum.
    waiting 4 u r reply,

    It could be that you have cookies turned off and you're not using URL Rewriting.
    In J2EE, the first time your browser makes a request to the server, the server responds and appends a SESSION_ID parameter to the request as well as storing a cookie with the SESSION_ID.
    The second time your browser makes a request, the server checks for the cookie. If it doesn't exist it checks for the parameter. If neither exist the server assumes its the first time your browser has made a request and behaves as describe in the previous paragraph.
    In your case when you submit the form if you have disabled cookies and the action attribute doesn't have the SESSION_ID paramter appended to the url, the browser will assume it's a first request. The user will not be logged in, hence your session has expired error.
    To fix this you need to encode the URL in your JSP. You can use the struts html:rewrite tag or the HttpServletReponse.encodeURL method, or if you're using JSP 2.0 the JSTL c:url tag.

  • I want to buy an in-app purchase but i don`t remember my security questions and i cant access my recovery email either, what can i do? i have 100$ on my account and cant use it because of that problem, please help URGENT

    I want to buy an in-app purchase but i don`t remember my security questions and i cant access my recovery email either, what can i do? i have 100$ on my account and cant use it because of that problem, please help URGENT

    If you have a rescue email address on your account then you can use that - follow steps 1 to 5 half-way down this page will give you a reset link on your account : http://support.apple.com/kb/HT5312
    If you don't have a rescue email address (you won't be able to add one until you can answer your questions) then you will need to contact Support in your country to get the questions reset : http://support.apple.com/kb/HT5699

  • Boot problem == pls HELP

    I have use the utility disk and format the machintos drive , and use  Extended (Journaled , Encrypted) , it ask me for a password (typed the password, confirmed the password - done) ,  after that i tried to install a fresh copy of Lion (i waited to be downloded from apple.com - done) after that it said that the fresh copy it will be installed and it will reboot by itself -> done ... from here the problem it's starting .... now my macbook air , it dosent start anymore it keep showming me, instaid of the apple sign from the start , a sign like the one from ghost busters (but without the ghost in it ) , i have tried to boot from cd , from usb , nothing dosent seams to be working.
    If anyone know a solution to this problem, pls HELP! Thank you in advance...
    p.s. before i had 2 hard drives that show up when i press the ALT button (machintos hd and utility drive, or something like that) now.. the only thing that it's showing me is : mac os base system , and if i try to use partition magic or something else, from a usb, it will tell me something about a bootguard , but i don't know how to insert the password.

    Glad your issue is fixed. Thanks for the update!
    Click if you want to Thank someone. If Problem is resolved, so that others can make use of it.

  • How to solve this problem, pls help when I try to see remote camera system from home."Dual streaming is required for HTML viewing"

    How to solve this problem, pls help when, I try to see remote camera system(spec dvr) from home. The Error I get is "Dual streaming is required for HTML viewing"

    I had the same probelm and found that the problem lies with 64bit programs such as safari and microsoft internet explorer. I have resolved the issue on my PC based server by using a 32 bit ie and same on my mac by using the same running windows under parallels.
    So far the problem with the 64 bit side of it is still to be resolved.
    Hope this helps and gets you guys up and running until suchtime a 64 bit solution is found.
    Craig

  • File to File Scenario with Secure Connection. Pls help urgent

    Hello All,
    I tried a lot to get a link/blog that expalin full scenario
    for File to File Scenario with Secure Connection
    Kindly let me know if somebody have link/doc for it
    that describe all the steps to do configuring this scenario.
    What is difference in simple words between
    FTPS and SFTP.
    Pls help it is urgent as I require for Project work urgently.
    Regards

    hi rich
    go through these links
    FTPs connection failed - error ".. certificate rejected by ChainVerifier"
    Re: What is SFTP, FTI channels
    http://help.sap.com/saphelp_erp2005/helpdata/en/e3/94007075cae04f930cc4c034e411e1/frameset.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/frameset.htm
    FTPS implementation question.
    http://help.sap.com/saphelp_nw04s/helpdata/en/43/0e16bfd7b021aee10000000a1553f6/frameset.htm
    Server certificate rejected by ChainVerifier:FTPS server(Points Guaranteed)
    /people/krishna.moorthyp/blog/2007/07/31/sftp-vs-ftps-in-sap-pi
    File adapter
    thanks
    Kunaal

  • Cannot use face time after upgrating to ios 6 .password is not recognisible.pls help urgently

    I cannot use face time after updating to IOS 6'password  is not recognisible here nor to imessage pls help urgently

    Using FaceTime http://support.apple.com/kb/ht4319
    Troubleshooting FaceTime http://support.apple.com/kb/TS3367
    The Complete Guide to FaceTime: Set-up, Use, and Troubleshooting Problems
    http://tinyurl.com/32drz3d
     Cheers, Tom

  • Import problem,pls help!

    Hi,there,
    I'm new guy here,I'v got a problem about Import in table mode,I found I can import back all records successfully, but it just appends all records into the orignal table,not overwrite
    it,for example, I made a export for a table with 2 records, after then I added some records into that table,
    finally I made an import for that table, I found the
    total of records is not recovered to 2,but just append
    the records from export file,why can't I recover it to 2
    record? pls help me,thanks!

    All that import does is to run a bunch of SQL statements based on the content of the export file. If you look at the export file in an editor (if its small), or through type (on Windoze) or more on *NIX you will see stuff like:
    CREATE TABLE x STORAGE ( ...)
    INSERT INTO x col12,col2, ...
    VALUES (:b1,:b2, ...
    If you give imp the paramter ignore=Y, then the error generated by the CREATE TABLE (table already exists) will be suppressed, but the ata will be inserted. Note that there are no DROP TABLE or TRUNCATE TABLE commands in the export file.
    If you want to restore your database to a particular point in time using import, then you will need to manually drop or truncate the tables first. You can generate the required sql from the data dictionary. something like
    SET lines 1000 pages 0 feedback off trimspool on;
    SPOOL drop.sql;
    SELECT 'DROP TABLE '||table_name||';'
    FROM user_tables;
    SPOOL OFF;
    @drop.sqlHTH
    John

  • Weird Problem pls help.

    Hi guys I have a big problem that I can't figure out. See I have a PT880 Neo and on the mobo box it says it's VIA. But when I go to install the Hyperion 4 in 1 mobo drivers my system crashes. When I boot up I get a Bsod stating my graphics card is in an infinite loop and says the video driver for my card is the problem. Also when I go to install new hardware it doesn't detect it. I checked the bios and pnp is enabled. So I put a new network card in and it will only detect it in the top pci slot so is this some kind of glitch am I downloaded the right drivers? The hyperion 4 in 1's version 455vp1 pls help

    I need your full system specs + PSU specs.
    Read these guides as well >Moan Guide Power Supply Guide

  • Upgradation problem pls help

    I imported my oracle 8.1.5 database dump in oracle 8.1.7 but when I want to connect to my instance thru a client machine one error message comes as "
    problem in connecting to the database, check whether it is started or contact sys admin" whereas the database is in open state.
    Then when I connected to sqlplus at the server, it gets connected but some messages also come as below"
    ORA-06553: PLS-213: package STANDARD not accessible
    Error accessing package DBMS_APPLICATION_INFO
    ERROR:
    ORA-06553: PLS-213: package STANDARD not accessible
    Could anyone pls help..

    What is the result of
    SQL> show parameter PLSQL_V2_COMPATIBILITY
    ?

  • Serious problem. pls help !!!!!!!!!

    some "khar, khar sound is coming from below of the keyboard of my hp g6 pavillion 2231 all the time when the lapton is on. what to do. i am fed off of that noise. pls help!!!!!!!!
    This question was solved.
    View Solution.

    Hi 
         Sorry khar khar ????   Mainly any sounds from under the keyboard would be Fan or HDD either way could mean either the Fan ( if fan ) is struggling to move due to dust build up OR the hard drive is failing  ,,, It's difficult to give you a firm answer without more information . Can you tell the difference between the fan noise and a hard drive noise ?? When you start up from cold does the noise start immedietly or is it only heard after say 5-10 minutes ??????           Checkurtech
    ****Click the White Kudos star to say thanks****
    ****Please mark Accept As Solution if it solves your problem****

  • Installation problem, pls help

    I am trying to install Oracle 10g on SUSE 10.0.0 but when i run the ./runInstaller command, I receive an[b] error of writting to directory /tmp/OraInstall2006-03........, Please ensure this directory is writable and at least 60MB of disk space, i have checked for space using df -h /tmp, there is enough space, i think the problem has got to do with permission because @ the moment it belongs to root user, i don't know what to do, i am a novice to unix and need to install oracle today. Pls help
    Usually the standard install of SuSE Linux should set the ownership and access rights to /tmp, if you want to give access to everyone on the system, just use this command (if owner/root access is available):
    I have used chmod o+rwx /tmp command and still having the same error. Pls somebody help
    chmod o+rwx /tmp

    Of course I assume you did correctly follow installation and configuration instructions. Did you read Oracle10g/Linux Errors and Problems from Werner Puschitz ?

  • Pls help, urgent... I'm giving out all my duke dollars...

    Hi, thanks for reading...
    My problem is I need to assignment some value into an variable when the "main" program start and I want the data inside this variable visible to all the class to use (by using the getter methods to get the value),
    For example: From the code below (the clsMain), it is possible to get the same value assigned into the "strGrandChildName" variable in the "main" program inside the "clsChild" class? Any idea how to make this thing work? pls help me... with some sample code... i really appreciate any help you guys can give.
    Thank You,
    Best Regards.
    public class clsGrandChild {
    private String strGrandChildName = "";
    public void mtd_setGrandChildName(String strIn) {
    strGrandChildName = strIn;
    public String mtd_getGrandChildName() {
    return strGrandChildName;
    public class clsChild {
    private String strChildName = "";
    public void mtd_setChildName(String strIn) {
    strChildName = strIn;
    public String mtd_getChildName() {
    return strChildName;
    public String mtd_GrandChildName() {
    // can i get the same value of strGrandChildName assigned in the main frm here?
    public class clsMain extends clsGrandChild {
    public static void main(String[] args) {
    mtd_setGrandChildName("grand child name");
    clsChild objChild = new clsChild();
    objChild.mtd_GrandChildName();

    public class clsGrandChild {
    private String strGrandChildName = "";
    public void mtd_setGrandChildName(String strIn) {
    strGrandChildName = strIn;
    public String mtd_getGrandChildName() {
    return strGrandChildName;
    public class clsChild {
    private String strChildName = "";
    public void mtd_setChildName(String strIn) {
    strChildName = strIn;
    public String mtd_getChildName() {
    return strChildName;
    public String mtd_GrandChildName() {
    // can i get the same value of
    alue of strGrandChildName assigned in the main frm
    here?
    public class clsMain extends clsGrandChild {
    public static void main(String[] args) {
    mtd_setGrandChildName("grand child name");mtd_setGrandChildName("grand child name") shouldn't be called here, it should be called after the
    clsChild object has been created
    >
    clsChild objChild = new clsChild();objChild. mtd_setGrandChildName("grand child name");
    objChild.mtd_GrandChildName();
    If to access the variable strGrandChildName before the instanciation of clsChild object is what you needed, then you will need to set the string strGrandChildName as static and also setter method
    needs to be static too.
    private static String strChildName = "";
    public static void mtd_setGrandChildName(String strIn) {
    strGrandChildName = strIn;
    by doing it this way, the static variables will be created when main thread starts.

  • Audio+Video Chat works but one small problem.Pls help.

    HI..
    as i had posted once before in a different query's thread, i have implemented audio and video chat using AVTRansmit2 and avreceive2.
    audio and video chat work well.By video chat i mean not only video but VIDEO+AUDIO as well.. just like usual yahoo video chat.
    But the problem is like this:-=
    I have given an option for user to switch from audio chat to video chat.
    now if a user first goes to audio chat and then switched to video chat,
    then the problem comes. When he's shifted to video chat i close down previous Audio chat by RTPManager.dispose() , i close the player and everything..
    and then i start Video transmit/receive "ALONG WITH" audio transmit/receive..
    No this time video starts but audio doesnt work ..
    it says"waiting for rtp data to arrive.... "
    The problem is that when this new stream of audio data comes, the receiver somehow thinks that its the same old stream since its from same transmitter IP.. and so it tries to UPDATE the previous stream.
    It means there is some problem with the close method or RTPManager.dispose() which should have disposed off all the stuff much before the new connection was made.
    PLS HELP ASAP>
    this is crunch time for my project.

    Hi anandreyvk . .
    well, i had tried doing removetargets and also, i had disposed RTPManager well. As it turns out the problem was not with any of it but it was the problem of me incorrectly passing RTPManager from AVReceive2 to AVTransmit2.
    Actually i am using just one RTPManager.. since i am receiving and transmitting on the same port.
    i've solved the problem but i am not sure if this is the right way .. what do you think ??
    is creating just one RTPManager {by that,i mean initializing it only once} a good idea ?? Since we are supposed to call both AVTransmit2 and AVReceive2 with the "LOCAL PORT" .. {which in itself is a matter of discussion though! } i and my project mate thought initializing RTPManager only once is a better option .
    Whats your take on all of this ?

Maybe you are looking for