Mail Archives: cygwin/2003/02/27/16:21:31
Gilles - The following should work for you under Cygwin:
HelloWorld.c:
-----------------------------------------------------------------
#include <iostream>
using namespace std;
#include "HelloWorld_jni.h"
JNIEXPORT void JNICALL
Java_HelloWorld_sayHello( JNIEnv *env, jclass c )
{
cerr << "Hello World from C!" << endl;
}
HelloWorld.java
--------------------------------------------------------------------
public class HelloWorld
{
private static native void sayHello();
public static void main( String[] args )
{
System.loadLibrary( "Native" );
sayHello();
}
}
go.csh:
------------------------------------------------------------------------------------
#!/bin/tcsh -v
set nonomatch
rm -rf ./bin
rm -f Native.dll *.o *.h
javac HelloWorld.java
javah -classpath . -o HelloWorld_jni.h HelloWorld
g++ \
-D_REENTRANT -D_GNU_SOURCE -D__int64='long long' \
-I${JAVA_HOME}/include -I${JAVA_HOME}/include/win32 \
-I. \
-Wl,--add-stdcall-alias -shared -o Native.dll HelloWorld.c
java -classpath . -Xmx256m -Djava.library.path=. HelloWorld
--------------------------------------------------------------------------------------
Make the 3 files indicated, type "go.csh", and it should work. This assumes you have java (I use java 1.4.1) installed on your machine, and that the environment variable JAVA_HOME is set to point to it (e.g. setenv JAVA_HOME c:/j2sdk1.4.1" or similar).
You should also checkout the excellent webpage on using JNI with Cygwin at:
http://www.inonit.com/cygwin/
Alan Thompson
At 12:28 PM 2/27/2003 +0100, you wrote:
hi folks,
I am currently using my JNI so/dll library under solaris, linux and cygwin.
with solaris and linux, no problem, I bind to it using load(..) since the
LD_LIBRARY_PATH is set.
BUT, under cygwin/windows, it does not work and I shall tell the absolute
path when I load the library.
I hav already posted in java.machine, but Randall schulz told me to try in
this mailing list.
thanks for help
gilles
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -