<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "jni example with terracotta"]]></title>
		<link>http://forums.terracotta.org/forums/posts/list/3.page</link>
		<description><![CDATA[Latest messages posted in the topic "jni example with terracotta"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>jni example with terracotta</title>
				<description><![CDATA[ Hi,

I'm having some difficulty with JNI setup for Terracotta.  Any suggestion on what I am doing wrong here? 

Thanks,
--Thanhy

#define USER_CLASSPATH "-Xbootclasspath/p:./lib/dso-boot-hotspot_linux_150_11.jar -Dtc.install-root=/danger/local/terracotta-2.6 -Dtc.config=  -Djava.class.path=./target/classes:./lib/ehcache-1.2.4.jar:./lib/commons-logging-1.0.4.jar:./lib/concurrent-1.0.jar:./lib/jcs-1.3.jar:./lib/tc.jar"

		main()
		{
			JNIEnv *env;
			JavaVMInitArgs vm_args;
			JavaVMOption options[1];
			options[0].optionString = USER_CLASSPATH;
			int i, rc, status;
			jint res;
			char classpath[1024];
			int total_threads = 10;
			pthread_t threads[total_threads];
			pthread_attr_t attr;

			/* IMPORTANT: specify vm_args version # if you use JDK1.1.2 and beyond */
			vm_args.version = 0x00010002;
			vm_args.options = options;
			vm_args.nOptions = 1;
			vm_args.ignoreUnrecognized = JNI_TRUE;

#if 0
			JNI_GetDefaultJavaVMInitArgs(&vm_args);

			/* Append USER_CLASSPATH to the end of default system class path */
			sprintf(classpath, "%s%c%s", vm_args.classpath, PATH_SEPARATOR, USER_CLASSPATH);
			vm_args.classpath = classpath;
#endif

			/* Create the Java VM */
			res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
			if (res < 0)
			{
				fprintf(stderr, "Can't create Java VM\n");
				exit(EXIT_FAILURE);
			}

			//
			// init()
			//
			jclass cls = (*env)->FindClass(env, "com/danger/cache/TCacheService");
			if (cls == 0)
			{
				fprintf(stderr, "Can't find com.danger.cache.TCacheService class\n");
				exit(EXIT_FAILURE);
			}

// ...

}]]></description>
				<guid isPermaLink="true">http://forums.terracotta.org/forums/posts/list/971.page#5864</guid>
				<link>http://forums.terracotta.org/forums/posts/list/971.page#5864</link>
				<pubDate><![CDATA[Mon, 14 Apr 2008 07:36:37]]> GMT</pubDate>
				<author><![CDATA[ gmather]]></author>
			</item>
			<item>
				<title>Re:jni example with terracotta</title>
				<description><![CDATA[ I don't know that we'll be able to help you - as we haven't really tried much JNI with Terracotta.  However, to start with, what error are you seeing?]]></description>
				<guid isPermaLink="true">http://forums.terracotta.org/forums/posts/list/971.page#5866</guid>
				<link>http://forums.terracotta.org/forums/posts/list/971.page#5866</link>
				<pubDate><![CDATA[Mon, 14 Apr 2008 08:28:02]]> GMT</pubDate>
				<author><![CDATA[ tgautier]]></author>
			</item>
			<item>
				<title>Re:jni example with terracotta</title>
				<description><![CDATA[ I got it!  Here's the code to create Terracotta-enabled JVM in c.

--Thanhy

		main()
		{
			JNIEnv *env;
			JavaVMInitArgs vm_args;
			JavaVMOption options[4];
			
			options[0].optionString = "-Xbootclasspath/p:./lib/dso-boot-hotspot_linux_150_11.jar";
			options[1].optionString = "-Dtc.install-root=/danger/local/terracotta-2.6";
			options[2].optionString = "-Dtc.config= ";			
			options[3].optionString = "-Djava.class.path= .:./target/classes:./lib/tc.jar";

			int i, rc, status;
			jint res;
			char classpath[1024];
			int total_threads = 10;
			pthread_t threads[total_threads];
			pthread_attr_t attr;

			/* IMPORTANT: specify vm_args version # if you use JDK1.1.2 and beyond */
			vm_args.version = 0x00010002;
			vm_args.options = options;
			vm_args.nOptions = 4;
			vm_args.ignoreUnrecognized = JNI_TRUE;

			/* Create the Java VM */
			res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
			if (res < 0)
			{
				fprintf(stderr, "Can't create Java VM\n");
				exit(EXIT_FAILURE);
			}

// ...

}]]></description>
				<guid isPermaLink="true">http://forums.terracotta.org/forums/posts/list/971.page#5867</guid>
				<link>http://forums.terracotta.org/forums/posts/list/971.page#5867</link>
				<pubDate><![CDATA[Mon, 14 Apr 2008 11:11:27]]> GMT</pubDate>
				<author><![CDATA[ gmather]]></author>
			</item>
			<item>
				<title>Re:jni example with terracotta</title>
				<description><![CDATA[ Wow.  Kewl!

What is this for though?

--Ari]]></description>
				<guid isPermaLink="true">http://forums.terracotta.org/forums/posts/list/971.page#5879</guid>
				<link>http://forums.terracotta.org/forums/posts/list/971.page#5879</link>
				<pubDate><![CDATA[Mon, 14 Apr 2008 18:47:58]]> GMT</pubDate>
				<author><![CDATA[ ari]]></author>
			</item>
	</channel>
</rss>