(So continues the JNI saga....)

I currently have this (in C++, this being my native code in C++):

(x is a jstring passed thru the header)

jdouble res;
	if (x=="*")
	{
		res=a*b;
	}
	else if (x=="+")
	{
		res=a+b;
	}
	else if (x=="-")
	{
		res=a-b;
	}
	else if (x=="/")
	{
		res=a/b;
	}
	else
	{
		res=-9999;
	}
	 return res;

but it says that jstring (x) and const char * (the things after the "==" for example the "*") are not compatible: "Error: operand types are incompatible ("jstring" and "const char *")"

Recommended Answers

All 2 Replies

Member Avatar for hfx642

a) Not everything in Java starts with a "J".

b) if (x.equals("*"))...

a) Not everything in Java starts with a "J".

b) if (x.equals("*"))...

This code is in C++, not Java. I believe variable dot something doesnt exist in C++ (AFAIK).

jstring is the same as const char * as stated in jni.h

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.