Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with calling constructor from JNI code

843829Sep 8 2010 — edited Sep 8 2010
I have no error when I am trying to call any method of the "Ursa_Routing_Output" object from the JNI code. But I am getting the same error when calling the constructor.

Problem with the Empty constructor
Exception in thread "Thread-23" java.lang.NoSuchMethodError: <init>
at com.comail.jni.UVSdk.getRPO(Native Method)

jclass jRpo=env->FindClass("com/comail/pojo/Ursa_Routing_Output");
  	if(jRpo==NULL)
  	{
  	 printf("Class can't be found \n");
  	 return NULL;
  	}


	jmethodID test=env->GetMethodID(jRpo,"getAreaCommitment","()Ljava/lang/String;");
	if(test==NULL)
  	{
  	printf("\nProblem with the Test Method \n");
	return NULL;
 	}
	
    jmethodID uroEmptyConst  = env->GetMethodID(jRpo,"<init>","()v");
	if(uroEmptyConst==NULL)
  	{
  	printf("\nProblem with the Empty constructor \n");
	return NULL;
 	}
The corresponding methods in the Java class are :
public class Ursa_Routing_Output implements Serializable {

	/**
	 *   Class fields 
	 */

       public Ursa_Routing_Output() {
		super();
		// TODO Auto-generated constructor stub
	}

   ...........
............

     public String getAreaCommitment() {
		return AreaCommitment;
	}
The corresponding class signatures generated through javap are :

public com.comail.pojo.Ursa_Routing_Output();
Signature: ()V

public java.lang.String getAreaCommitment();
Signature: ()Ljava/lang/String;


The code is able to find the class and its other methods. But it is not able to locate the constructor.

Can any one help me to locate the problem?

Comments

Teresa Modesta
Answer

Hi,

I had similar on a client site where the local techies gave us such limited access that we could not use java as we should.

A workaround we found was to call the jar via a .bat and use the .bat as the shortcut, the .bat explicitly pointing to the elements along these lines; -

echo off

"C:\Program Files\Java\jdk1.8.0_144\bin\java.exe" -classpath c:\Java\MyJavaJarIsHere;c:\Java\BusinessContinuity\MyJar.jar;lib/* MyJar

This worked for me, I am sure it is far from best practise, it was a sub-optimal workaround adopted because of sub-optimal local IT...

Marked as Answer by RosyCross · Sep 27 2020
RosyCross

Thank you, this worked for me also!

1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 6 2010
Added on Sep 8 2010
2 comments
2,574 views