problem while getting Vector object in native C++ method.

Discussion in 'Java' started by shivaraj, Dec 21, 2006.

  1. shivaraj

    shivaraj Guest

    Hi,

    I am trying to use declare a new Vector object and then call it's
    addElement method in native C++ method. I am facing some issue with
    "jmethodID vectConstructor =
    env->GetMethodID(vectorClass,"<init>","()V");"
    as its throwind exception as
    "excpection occuredException in thread "main"
    java.lang.NoSuchMethodError: <init>"

    Here with the steps i am running...

    1. jclass vectorClass = env->FindClass("java/util/Vector");
    if(vectorClass)
    printf("\n not null");
    else
    printf("\n null");
    2. jmethodID vectConstructor =
    env->GetMethodID(vectorClass,"<init>","()V");
    3. jobject result = env->NewObject(vectorClass, vectConstructor);
    4. jmethodID add = env->GetMethodID(vectorClass, "addElement",
    "(Ljava/lang/Object;)V");

    but after the first step the result is "null". So what I suspect is its
    not able to get "java/util/Vector" class. How do I resolve this
    problem? Do i need to add any specific header files for this or do I
    need to set something in CLASSPATH ? Please help me to resolve this.
    shivaraj, Dec 21, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jabel D. Morales - VMan of Mana

    Problems with JNI: calling a Java method from native method.

    Jabel D. Morales - VMan of Mana, Aug 1, 2003, in forum: Java
    Replies:
    1
    Views:
    4,730
    Joseph Millar
    Aug 1, 2003
  2. pmatos
    Replies:
    6
    Views:
    23,705
  3. Replies:
    8
    Views:
    1,877
    Csaba
    Feb 18, 2006
  4. Javier
    Replies:
    2
    Views:
    533
    James Kanze
    Sep 4, 2007
  5. Rushikesh Joshi
    Replies:
    0
    Views:
    338
    Rushikesh Joshi
    Jul 10, 2004
Loading...

Share This Page