Go Back   Velocity Reviews > Newsgroups > Java
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Java - How to Compile JNI program on windows/cygwin

 
Thread Tools Search this Thread
Old 05-31-2006, 09:08 PM   #1
Default How to Compile JNI program on windows/cygwin


Hi,

I am working on windows xp, java(jdk1.5.0_06) installed on it. I dont
have developer studio. i installed cygwin and gcc, make working fine on
cygwin.

now i would like to compile a simple JNI program. but i am getting so
many errors like this.

JavaSide.java:
public class JavaSide {
public native void sayHello();

static {
System.loadLibrary("NativeSideImpl");
}

public static void main(String[] args) {
JavaSide app = new JavaSide();
app.sayHello();
}
}
------------------------------------------
NativeSideImpl.cpp:

#include <stdio.h>
#include "JavaSide.h"

JNIEXPORT void JNICALL Java_JavaSide_sayHello
(JNIEnv *env, jobject obj)
{
printf("Hello Native World!");
}
---------------------------------------------

steps i followed is:
1) javac JavaSide.java
2) javah JavaSide
3) gcc -I /cygdrive/c/Program Files/Java/jdk1.5.0_06/include/ -I
/cygdrive/c/Program Files/Java/jdk1.5.0_06/include/win32
NativeSideImpl.cpp

Now i am getting so may errors like this

In file included from /cygdrive/c/Program
Files/Java/jdk1.5.0_06/include/jni.h:27,
from JavaSide.h:2,
from NativeSideImpl.cpp:2:
/cygdrive/c/Program Files/Java/jdk1.5.0_06/include/win32/jni_md.h:16:
error: `__int64' does not name a type
In file included from JavaSide.h:2,
from NativeSideImpl.cpp:2:
/cygdrive/c/Program Files/Java/jdk1.5.0_06/include/jni.h:108: error:
`jlong' does not name a type
/cygdrive/c/Program Files/Java/jdk1.5.0_06/include/jni.h:307: error:
expected identifier before '*' token
/cygdrive/c/Program Files/Java/jdk1.5.0_06/include/jni.h:308: error:
ISO C++ forbids declaration of `jlong' with no type
/cygdrive/c/Program Files/Java/jdk1.5.0_06/include/jni.h:308: error:
`jlong' declared as function returning a function
/cygdrive/c/Program Files/Java/jdk1.5.0_06/include/jni.h:308: error:
ISO C++ forbids declaration of `CallLongMethod' with no type
/cygdrive/c/Program Files/Java/jdk1.5.0_06/include/jni.h:308: warning:
`__stdcall__' attribute only applies to function types


Can any one please help me in compiling this simple program.

Thanks in advance.
Suresh



Suresh
  Reply With Quote
Old 05-31-2006, 09:20 PM   #2
Gordon Beaton
 
Posts: n/a
Default Re: How to Compile JNI program on windows/cygwin
On 31 May 2006 13:08:26 -0700, Suresh wrote:
> I am working on windows xp, java(jdk1.5.0_06) installed on it. I dont
> have developer studio. i installed cygwin and gcc, make working fine on
> cygwin.
>
> now i would like to compile a simple JNI program. but i am getting
> so many errors like this.


I googled for cygwin gcc jni and this was the second hit:

http://www.inonit.com/cygwin/jni/helloWorld/c.html

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e


Gordon Beaton
  Reply With Quote
Old 06-01-2006, 12:42 AM   #3
Suresh
 
Posts: n/a
Default Re: How to Compile JNI program on windows/cygwin

Thank you Mr Gordon.

This link helped me solving my problem.

--Suresh



Suresh
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
This is incredible! jc_ice DVD Video 1 08-13-2006 10:47 AM
Get Rich Daun Johnson A+ Certification 0 01-31-2006 03:11 PM
make lots O money fast an easy migeul A+ Certification 0 03-06-2004 01:45 AM
Been around for a while but very effective Paul A+ Certification 0 02-29-2004 12:14 PM
Re: free email addresses finding program (files included) Leonardo A+ Certification 1 12-05-2003 03:51 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46